R/factors.R

#' Indicate columns of a data frame as factors
#'
#' @title Factorize variables
#' @param data     The data frame
#' @param tofactor A vector indicating the column names of the column which should be factorized.
#' @return Data frame
#' @export
as.factors <- function (data, tofactor) {
  data[,tofactor] <- lapply(data[,tofactor], as.factor)
  return(data)
}
thomas-hinterecker/Ragbu documentation built on May 8, 2019, 9:46 a.m.