R/fix_levels.R

Defines functions fix_levels

Documented in fix_levels

fix_levels <-
function(x, sep="_")
{
    if (!is.factor(x))
        stop("x must be a factor")
    sep <- as.character(sep)
    if (length(sep) > 1L)
        stop("sep length must be 1")
    if (identical(getOption("ocoptions")$collapse, sep))
        stop("Nice try, but collapse option and sep argument are identical.")
    levels(x) <- gsub(getOption("ocoptions")$collapse, sep, x, fixed=TRUE)
    x
}

Try the opticut package in your browser

Any scripts or data that you put into this service are public.

opticut documentation built on May 2, 2019, 5:09 a.m.