我有一个非常基本的R问题,但我很难找到正确的答案.我有一个如下所示的数据框:
Run Code Online (Sandbox Code Playgroud)ind<-rep(1:4,each=24) hour<-rep(seq(0,23,by=1),4) depth<-runif(length(ind),1,50) df<-data.frame(cbind(species,ind,hour,depth)) df$depth<-as.numeric(df$depth)
我希望它选择并将深度<10(例如)的所有行替换为零,但我希望保留与这些行相关的所有信息以及数据框的原始尺寸.
我尝试了以下但这不起作用.
Run Code Online (Sandbox Code Playgroud)ind<-rep(1:4,each=24) hour<-rep(seq(0,23,by=1),4) depth<-runif(length(ind),1,50) df<-data.frame(cbind(species,ind,hour,depth)) df$depth<-as.numeric(df$depth)
有什么建议?