ex1 <- c('Y', 'N', 'Y') ex2 <- c('Y', 'N', 'Y') ex3 <- c('N', 'N', 'Y') ex4 <- c('N', 'N', 'Y')
status <- array(NA, dim=3) # I am trying to return 'Okay' if any of the values # in a column above is 'Y' but I am not constructing # the function corrrectly. Any assistance is # greatly appreciated status_fnc <- function(e){ if (e[ ,1] == 'Y' | e[ ,2] == 'Y' | e[ ,3] == 'Y' | e[ ,4] == 'Y'){ return('Okay') } else return('Not okay') } status <- sapply(cbind(ex1, ex2, ex3, ex4), status_fnc) [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org 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.