When I run the below section of code I get the following error:
Error in if (co == "A" || co[1] == "O") { :
missing value where TRUE/FALSE needed
When I run the code in two parts where I first get the user's input
then afterwards run the if/else section, there is no problem.
Is there a way to stop the "run selection" process until the user
has input a value?
------------------------------------------------------------------------
-----
calc_option <- function(){
msg <- cat("Please select an option:\n"," 'O'ne or 'A'll':
")
co <- readline(msg)
switch(co,
O = "O", o = "O",
A = "A", a = "A"
)
}
co <- calc_option()
if (co == "A" || co[1] == "O") {
print(paste("calc_option = ", co))
} else {
print("calc_option is not acceptable")
}
Thanks,
- Bruce
**********************************************************************
Please be aware that, notwithstanding the fact that the pers...{{dropped}}
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.