Displaying 1 result from an estimated 1 matches for "qs9".
Did you mean:
qs
2003 Oct 07
3
Problem getting an ifelse statment to work
This is a "long" way; i.e., not necessarily efficient:
> qs2
[1] 2 1 1 4 4 4 1 1 1 4 2 4 3 1 4 3 3 2 4 3
> qs9
[1] 4 4 1 3 4 3 1 3 1 4 1 2 3 3 4 4 1 4 2 3
> decision <- function(a, b) {
+ if (a == 1 || b == 1) return(1)
+ if (a == 2 || b == 2) return(2)
+ if (a == 3 || b == 3) return(3)
+ if (a == 4 || b == 4) return(4)
+ NA
+ }
> mapply(decision, qs2, qs9)
[1] 2 1 1 3 4 3 1 1...