R/read.R

Defines functions read.csv3 .natoempty

Documented in read.csv3

.natoempty <- function(test) {
    if (is.character(test) | sum(is.na(test)) == length(test)) {
        return(ifelse(is.na(test), "", test))
    } else {
        return(test)
    }
}

#' Read Data in with Empty Cells to Empty Strings
#'
#' @param ... Arguments to be passed to read.csv
read.csv3 <- function(...) {
    temp <- read.csv(...)
    for (col in colnames(temp)) {
        temp[,col] <- .natoempty(temp[,col])
    }
    return(temp)
}
mattgarber4/myUtils documentation built on Dec. 13, 2020, 12:54 p.m.