View source: R/impute_missing.R
impute_missing | R Documentation |
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.
impute_missing(data)
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
{ # 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.