Description Usage Arguments Value Author(s) Examples
View source: R/impute_missing.R
This function imputes missing abundances by sampling the known values from each variable. The values are sampled according to the distribution, i.e. the most frequent values have a better chance of being chosen.
1 |
data |
Data frame with abundances values. Note that this function should only be used with the raw data (counts) |
Imputed data frame
Laura M Zingatetti
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | {
# toy example. To simulate 13 missing columns with less than 50 \% of missing values in each.
data('Ruminotypes')
Data<-Ruminotypes$`16_S`
#13 indicates the number of columns with missing values.
Columns<-sample(1:ncol(Data),13)
for (i in Columns){
n<-sample(1:30,1)
Data[sample(1:nrow(Data),n),i]<-NA
}
A<-impute_missing(Data)
#check precision of imputed data
cor(A[,Columns[1]],Ruminotypes$`16_S`[,Columns[1]])
cor(A[,Columns[2]],Ruminotypes$`16_S`[,Columns[2]])
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.