DNAm-based-age-predictor icon indicating copy to clipboard operation
DNAm-based-age-predictor copied to clipboard

Error in if (args[i] == "-i") { : missing value where TRUE/FALSE needed

Open MinS1 opened this issue 2 years ago • 1 comments

Hi, Dear Qian,

When I run source("pred.R"), I received this error message: Error in if (args[i] == "-i") { : missing value where TRUE/FALSE needed

Do you know what this means and how can I solve it? Thank you!

Best wishes, Shi

MinS1 avatar Nov 15 '22 09:11 MinS1

Hello there,

I will reply in case anyone else has this issue. This occurs only when trying to run the source code. If You run the script using command line, this issue will not appear.

It happens due to arguments provided in the command line not being available while running the source code, to fix it and run the script you can include input files like this(lines 23-25):

infile<-c("data.rds")                     ########## input file name
outfile<-c("age.pred")                    ########## output file name
agefile<-c("data.age")                    ########## file with individual ID and age

and remove the check for arguments(lines 27-35):

# for(i in 1:(length(args)-1)){
#        if(args[i]=="-i"){
#                infile<- args[i+1]
#        }else if(args[i]=="-o"){
#                outfile<- args[i+1]
#        }else if(args[i]=="-a"){
#                agefile<- args[i+1]
#        }
#}

Good luck, Woo

woohoos avatar Nov 20 '23 11:11 woohoos