groupImpute: groupImpute

Description Arguments Details Value Author(s) Examples

View source: R/groupImpute.r

Description

Impute by groups

Arguments

dataframe

A dataframe containing missing data to be imputed.

...

One or more grouping vectors by which dataframe should be split before imputation.

method

A character string specifying the method by which missing data should be imputed. One of “mean” (mean replacement; the default), “median” (median replacement), “draw1” (sample with replacement), or “draw2” (sample without replacement).

Details

Function to impute missing data in a dataframe, based upon grouping factor(s).

Value

A dataframe

Author(s)

Thomas J. Leeper

Examples

1
2
3
4
n <- 100
mydf <- data.frame(t=sample(1:5,n,TRUE), x=rnorm(n), y=rnorm(n), z=rbinom(n,1,.5))
mydf[cbind(sample(1:nrow(mydf),20,TRUE),sample(2:ncol(mydf),20,TRUE))] <- NA
groupImpute(mydf,mydf$t,mydf$z)

leeper/expResults documentation built on May 21, 2019, 12:37 a.m.