[R] Compare three or more values?
Beale, Holly (NIH/NHGRI) [F]
holly.beale at nih.gov
Wed Mar 23 17:01:20 CET 2011
Is there a less cryptic way to compare three or more values?
allTheSame<-c("red","red","red","red")
notAllTheSame<-c(132,132,132,999)
all.identical <- function(vectorToTest){
cIdentical=sum(vectorToTest %in% vectorToTest[1])
return(cIdentical==length(vectorToTest))
}
all.identical(allTheSame)
all.identical(notAllTheSame)
Thanks in advance,
Holly
More information about the R-help
mailing list