R/get_cat_data.R

Defines functions get_cat_data

Documented in get_cat_data

#' Getting categorical data
#'
#' This function takes a datatable and slices only categorical data
#'
#' @param  a data table
#' @return a data table with categorical features
#' @export
get_cat_data <- function(DT) {
  if (!is.data.table(DT)) {
    DT <- as.data.table(DT)
  }
  bool <- sapply(DT[sample(1:nrow(DT), 100)], class) %in% c("integer", "numeric")
  DT <- DT[, !bool, with = FALSE]
  return(DT)
}
tw1118/myutilitypackage documentation built on May 16, 2019, 9:13 p.m.