fac.uncombine {dae}R Documentation

Cleaves a single factor, each of whose levels has delimited strings, into several factors using the separated strings.

Description

Cleaves a single factor into several factors whose levels, the levels of the original factor consisting of several delimited strings that can be separated to form the levels of the new.factors. That is, it reverses the process of combining factors that fac.combine performs.

Usage

fac.uncombine(factor, new.factors, sep=",", ...)

Arguments

factor

A factor or character that has values that are strings deleimited by the delimiter specified by sep.

new.factors

A list, whose component names are the names of the new factors to be formed. If a component is not NULL, then they are used as the levels of the corresponding factor.

sep

A character string that separates the levels of the new.factors in the levels factor.

...

Further arguments passed to the factor call creating the new factor.

Value

A data.frame whose columns consist of the factors listed in new.factors and whose values have been computed from the values of the combined factor.

Author(s)

Chris Brien

See Also

fac.split, fac.combine, fac.divide in package dae and strsplit.

Examples

## set up two factors and combine them
facs <- fac.gen(list(A = letters[1:3], B = 1:2), each = 4)
facs$AB <- with(facs, fac.combine(list(A, B), combine.levels = TRUE))

## now reverse the proces and uncombine the two factors
new.facs <- fac.uncombine(factor = facs$AB, 
                          new.factors = list(A = letters[1:3], B = NULL), 
                          sep = ",")
new.facs <- fac.uncombine(factor = facs$AB, 
                          new.factors = list(A = NULL, B = NULL), 
                          sep = ",")

[Package dae version 3.2.28 Index]