R/simplifyDF.R

Defines functions simplifyDF

Documented in simplifyDF

simplifyDF <-
function(d, stringsAsFactors=FALSE) {
  convert_numeric_to_int <- function(x) {
    ret <- if(is.numeric(x)) {
             if(all(x == as.integer(x))) {
               as.integer(x)
             } else {
               x
             }
           } else {
             x
           }
    ret
  }

  as.data.frame(lapply(d, convert_numeric_to_int), stringsAsFactors=stringsAsFactors)
}
vlulla/vlutils documentation built on May 21, 2019, 12:35 a.m.