Displaying 2 results from an estimated 2 matches for "datatrait".
Did you mean:
datatrain
2009 Jun 09
4
how to substitute missing values (NAs) by the group means
...lem by using doBy package. But, I
failed. I ask for the right solutions by using doBy package or not.
The commands used and the output I got are as followed:
library(doBy)
df<-orderBy(~group,data=df) # succeeded
f1<-function(x){m<-mean(x, na.ram=TRUE); x[is.na(x)]<-m; x} # succeeded
datatraits<-lapplyBy(traits~group,data=df, FUN=f1(traits)) # failed
errors: mean(x, na.ram = TRUE), can not find 'traits'.
Thanks in advance.
Sincerely,
Mao J-F
[[alternative HTML version deleted]]
2009 Jun 09
1
how to use "lapplyBy" function of "doBy" package
...failed. I ask for the advice on how to use "lapplyBy" function of "doBy"
package.
The commands used and the output I got are as followed:
library(doBy)
df<-orderBy(~group,data=df) # succeeded
f1<-function(x){m<-mean(x, na.ram=TRUE); x[is.na(x)]<-m; x} # succeeded
datatraits<-lapplyBy(traits~group,data=df, FUN=f1(traits)) # failed
errors: mean(x, na.ram = TRUE), can not find 'traits'.
dummy dataframe:
> df
group traits
1 BSPy01-10 NA
2 BSPy01-10 7.3
3 BSPy01-10 7.3
4 BSPy01-11 5.3
5 BSPy01-11 5.4
6 BSPy01-11 5.6
7 BSPy01...