[R] Substituting numerical values using `apply'
Olivella
olivella at wustl.edu
Wed Jul 8 22:25:22 CEST 2009
Hello,
I wish to perform a substitution of certain numerical values in a data
matrix with the corresponding column name. For instance, if I have a data
matrix
V1 V2 V3
2 0 1
0 1 2
1 5 0
5 0 0
I want to substitute the `1' and the `2' for the corresponding column name,
and make everything else `NA' like this
V1 V2 V3
V1 NA V3
NA V2 V3
V1 NA NA
NA NA NA
I have done this using an explicit `for' loop, but it takes a really long
time to finish. Is there any way I can do this using `apply' or some form of
implicit looping?
Thank you for your help,
SO
--
View this message in context: http://www.nabble.com/Substituting-numerical-values-using-%60apply%27-tp24398687p24398687.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list