[R] ifelse, evaluating to given number

Peter Wilkinson pwilkinson at videotron.ca
Mon Jul 19 01:08:16 CEST 2004


I would like to take advantage of the  vectorized 'ifelse' command. Given a 
filter number of 'filter', if the nm'th value in a n x m matrix I would 
like to perform the following.

newMatrix <- ifelse(myMat <=filter, filter+1, "existing nm'th value").

What do I use to express the "existing nm'th value" in this expression if I 
want to test an nm th value is less than 'filter', if false use the 
existing nm'th value.

This does not seem to be documented in the help().

Peter W.




More information about the R-help mailing list