R/to.factor.R

Defines functions to.factor

Documented in to.factor

#' @title Set Factor Class
#'
#' @param x the data that you want to set
#' @param levels levels, the first levels is the reference. If the length of levels is 1, no levels will be given to x
#'
#' @return factor x
#' @export
#'
#' @examples
#' to.factor(mtcars$gear,c(4,3,5))
#' to.factor(mtcars$gear)
to.factor <- function(x,levels){
    if (missing(levels)){
        factor(x)
    }else{
        factor(x,levels = levels)
    }
}
yikeshu0611/fastStat documentation built on Nov. 18, 2019, 11:23 a.m.