impute_missing: impute_missing

View source: R/impute_missing.R

impute_missingR Documentation

impute_missing

Description

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.

Usage

impute_missing(data)

Arguments

data

Data frame with abundances values. Note that this function should only be used with the raw data (counts)

Value

Imputed data frame

Author(s)

Laura M Zingatetti

Examples

{
# 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]])
}




lauzingaretti/LinkHD documentation built on March 7, 2023, 9:21 a.m.