> -----Original Message-----
> testseq<-seq(1:20)
> testchange<-ifelse(testseq<=4,'x',testseq)
> testchange<-c(ifelse(testseq<=4,'x',testseq),ifelse(testseq>=5,'y',testseq))
> 
> The last instruction causes the vector 'testchange' to change dimensions,

Of course it does. ifelse(test, yes, no) returns a vector of length 
length(test). Your last line concatenates two of them, so you'll get a vector 
of length 40.

You might also want to note that you are replacing numbers with character 
strings, so 
ifelse(testseq<=4,'x',testseq)

will return four 'x's and then - because R has to coerce everything to a single 
type - character representations of numbers 5:20. That will not then respond 
well to subsequent numeric comparisons ...

S Ellison


*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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