dfTidy: Tidy Up a Data Frame

View source: R/dfTidy.R

dfTidyR Documentation

Tidy Up a Data Frame

Description

Tidy up a data frame with respect to missing values, internal quotes, and white space.

Usage

dfTidy(df, missNums = c(-9999, -999.9, -999, 999, 9999),
  missChars = c("NA", "NULL", "."))

Arguments

df

A data frame to be tidied.

missNums

A numeric vector of numbers representing missing values in df, default c(-9999, -999.9, -999, 999, 9999).

missChars

A character vector of strings representing missing values in df, default c("NA", "NULL", ".", " ", " ").

Details

Missing values in df are replaced with NA for numeric vectors and "" for character vectors. Internal quotes and leading and trailing white space in character vectors are removed. Attempt is made to convert any character vectors of numbers to numeric.

Value

A tidied version of the original data frame.

Examples

mydat <- data.frame(a=c(1, 2, -999, 4, 5),
 b=as.factor(c("cat ", " dog", "frog", ".", " ant")),
 c=c("1.2", "NULL", "3.4", "5.6", "7.8"),
 stringsAsFactors=FALSE)
dfTidy(mydat)


krphillips/EchoNet2Fish documentation built on March 19, 2022, 11:59 p.m.