impute_missing: impute_missing

Description Usage Arguments Value Author(s) Examples

View source: R/impute_missing.R

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

1

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

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

Yuliaxis/LinkHD documentation built on April 9, 2020, 12:02 a.m.