Hi,
Try:
 vec1<-c(1,1,1,1,1,1,1,1,1)
if(all(vec1==1)) "xxxxxxxxx" else  "yyyyyyyyyyy"
#[1] "xxxxxxxxx"
 vec2<-c(rep(1,4),2)
 if(all(vec2==1)) "xxxxxxxxx" else  "yyyyyyyyyyy"
#[1] "yyyyyyyyyyy"

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


A.K.

>Hi. 
>
>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) { 
>"xxxxxxxxxxxxxxxxxx" 
>} else { 
>"yyyyyyyyyy" 
>} 
>
>How can I write the condition "all values equal" in R? 
>
>Thank you

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to