Re: [R] Function on an array

2014-10-08 Thread Sven E. Templer
Dear Barry, some thoughts: 1) e in your function status_fnc is a vector when applied on a matrix like object, but you index it as a matrix (e[,i] should be e[i]). 2) You can simplify the if statement by using the function any (replacing all the OR statements) on the vector, so use any(e=='Y') her

[R] Function on an array

2014-10-08 Thread Barry King
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