Re: [R] Substituting numerical values using `apply'

2009-07-09 Thread Santiago Olivella
Thank you all for your help. SO. Henrique Dallazuanna wrote: > Try this: > > sapply(names(DF), function(n)ifelse(DF[,n] %in% c(1, 2), n, NA)) > > Where DF is your data.frame > > On Wed, Jul 8, 2009 at 5:25 PM, Olivella <mailto:olive...@wustl.edu>> wrote: >

[R] Substituting numerical values using `apply'

2009-07-08 Thread Olivella
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 201 012 150 500 I want to substitute the `1' and the `2' for the corresponding column name,