define data set
test <- data.frame(
stringsAsFactors = FALSE,
meastype = c(373, 373, 373, 373, 372, 372, 414, 414, 414, 414),
n=c(250,40,395,41,150,3456,2310.2,334.5,4459.5,2223),
totalcase = c(15, 10, 1, 9, 2500, 356, 30, 29, 40, 10),
note = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
outlier = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA),
warning = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
)
atype <- 1
if (atype != 5) {
do nothing
test1 <- test
} else {
define Small N if meastype is 373
if (meastype==373){
test1 <- test %>%
mutate(n=ifelse(totalcase==1,totalcase,n)) %>%
mutate(note=ifelse(NaN<n<10,3,note)) %>%
mutate(outlier=ifelse(NaN<n<10,'N',outlier)) %>%
mutate(warning=ifelse(NaN<n<10,4,warning))
} else {
# do nothing
test1 <- test}
}
variable atype controls the program flow . When it was set to 1, I thought that test1 would be generated as same as test. But the program went to 'define small N ' section with error. When it was set to 5, the result was same with same error message: "Error: unexpected '<' in:..... What is the problem and how to fix it? Thanks in advance!