I am having some trouble debugging my nested ifelse statement.
It runs the first part just fine, then won't run the second ifelse
statement. I have tried reversing the order of the statements. I have several functions that work similarly. I don't understand why the second half is not running like it's supposed to.
If math, read, write are all read "pass", then the element in the Result vector should be "Pass", if there is a"yes" Exempt column then the element in the result vector should be "Exempt" everything else should read "Not Pass".
Math <-c("Pass", "Not Pass", "Not Pass", "NA", "NA", "NA")
Read<-c("Pass","Pass","Not Pass", "NA", "NA", "NA")
Write<-c("Pass","Pass", "Not Pass", "NA", "NA", "NA")
Exempt<-c( "NA", "NA", "NA","yes","yes","yes")
dat<-cbind(Math,Read,Write,Exempt)
dat$Result <-
ifelse(dat$math=="Pass" & dat$Read=="Pass" & dat$writing == "Pass",
"Pass",
ifelse(dat$Exempt == "yes", "Exempt", "Not Pass"))