Answers for "how to throw an error in R"

0

how to throw an error in R

x <- ifelse(x < 0 | x > 1, NA, x )
 if( any(is.na(x)) ) warning('x not between 0 and 1')
 log(x / (1 - x) )
Posted by: Guest on August-08-2020
0

how to throw an error in R

logit <- function(x){
 if( any(x < 0 | x > 1) ) stop('x not between 0 and 1')
 log(x / (1 - x) )
}
Posted by: Guest on August-08-2020
0

how to throw an error in R

> logitpercent(c('50%','150%'))
Error in logit(as.numeric(x)/100) : x not between 0 and 1
Posted by: Guest on August-08-2020

Browse Popular Code Answers by Language