fix_NA: Replace cryptic NAs with standard NA

Description Usage Arguments References Examples

Description

This function will fix every column in a data.frame for possible missing value codes. It should be used if the test_NA() function identifies cryptic NAs in your data.frame, or if you have a custom NA indicator that you want to fix. A list of missing value codes to check can be found in White et al. 2013.

Usage

1
fix_NA(dat, custom_NAs = list(), leave_in = list(), removeFactors = TRUE)

Arguments

dat

input dataset. Currently only supports data.frame but will soon support data.table

custom_NAs

additional NA aliases you want to fix. Be sure to create a list if you want to include NA aliases of different classes.

leave_in

NA aliases that were identified by test_NA but should NOT be treated as such when cleaning the dataset. If more than one, the arguments should be a list.

removeFactors

Should columns be converted from factors after fixing for NA aliases? (Conversion to factors happens by default in correction process.) Strongly recomment the TRUE default.

References

2 Ethan P. White, Elita Baldridge, Zachary T. Brym, Kenneth J. Locey, Daniel J. McGlinn, and 3 and Sarah R. Supp. 1 Nine simple ways to make it easier to (re)use your data. PeerJ PrePrints. , doi: 10.7287/peerj.preprints.7v2

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
data(iris)
dat <- data.frame(
date = rep(as.Date("2014-01-01"),10),
num = c(rep(1,8),999,"n/a"),
name = c("NULL","naa",rep("foo",8))
)
test_NA(dat)
correct_NA(dat,custom_NAs="naa")

## End(Not run)

muschellij2/testdat documentation built on May 23, 2019, 9:56 a.m.