[R] vectors with equal values

arun smartpink111 at yahoo.com
Thu Apr 18 16:08:21 CEST 2013

if(all(vec1==1)) "xxxxxxxxx" else  "yyyyyyyyyyy"
#[1] "xxxxxxxxx"
 if(all(vec2==1)) "xxxxxxxxx" else  "yyyyyyyyyyy"
#[1] "yyyyyyyyyyy"

if(length(unique(vec1))==1) "xxxxxxxxx" else  "yyyyyyyyyyy"
#[1] "xxxxxxxxx"
  if(length(unique(vec2))==1) "xxxxxxxxx" else  "yyyyyyyyyyy"
#[1] "yyyyyyyyyyy"


>I need some help. I have a vector like c(1,1,1,1,1,1,1,1,1), for example. I wanto to do in R some like this: 
>if (all values equals) { 
>} else { 
>How can I write the condition "all values equal" in R? 
>Thank you

More information about the R-help mailing list