[R] data frame question

K. Elo maillists at nic.fi
Fri Feb 15 07:29:23 CET 2008


Hi,

joseph wrote (15.2.2008):
> Thanks. I have another question:
> In the following data frame df, I want to replace all values in col1
> that are higher than 3 with NA. df= data.frame(col1=c(1:5, NA),col2=
> c(2,NA,4:7))

My suggestion:

x<-df$col1; x[ x>3 ]<-NA; df$col1<-x; rm(x)

-Kimmo



More information about the R-help mailing list