impute_NA_covariate: Impute / copy over missing covariate values in a data.frame

Description Usage Arguments Value Author(s) References Examples

View source: R/impute_NA_covariate.R

Description

Impute / copy over missing covariate values in a data.frame

Usage

1
impute_NA_covariate(XX, colname_01, colname_02, stop_if_both_missing = TRUE)

Arguments

XX

data.frame with two columns to be copied one from another

colname_01

character name of column with possibly NA values.

colname_02

character name of column with possibly NA values.

stop_if_both_missing

logical whether to stop() if both entries are missing.

Value

An R data.frame with identical columns under colname_01 & colname_02.

Author(s)

Bill Forrest <forrest@gene.com>

Bill Forrest forrest@gene.com

References

www.r-project.org

Examples

1
2
3
4
5
6
7
8
9
 test_levels <- c( 'one', 'two', 'three', 'four' )
 DF_with_NA <-
  data.frame( First  = factor( c(    NA, 'two', NA, 'four' ), levels = test_levels ),
              Second = factor( c( NA,  NA, 'three', NA ), levels = test_levels ),
              Third = factor( test_levels, levels = test_levels )
             )
 DF_imputed_12 <- maeve:::impute_NA_covariate( DF_with_NA, 'First', 'Second',
                                               stop_if_both_missing = FALSE )
 DF_imputed_13 <- maeve:::impute_NA_covariate( DF_with_NA, 'First', 'Third'  )

wfforrest/maeve documentation built on Jan. 1, 2021, 12:47 p.m.