or {quickcode} | R Documentation |
Alternative return for statements
Description
Return alternative if the value of expression is empty or NA or NULL
Usage
or(test, alternative)
test %or% alternative
Arguments
test |
an object to return |
alternative |
alternative object to return |
Value
value of test if not null or empty, else return value of alternative
test1 <- c(4,NA,5,2,0,21)
test2 <- data.frame(ID = 1:10,ED = LETTERS[10:1])
or(test1[which(test1==4)],100)
or(test1[which(test1==43)],100)
or(test2[which(test2$ID == 10),2],"BBBBB")
or(test2[which(test2$ID == 323),2],"CCCCC")
# One may also choose to use test2[which(test2$ID == 323),2] NA NULL ""
[Package quickcode version 0.9.1 Index]