fac.split {dae} | R Documentation |
Splits a factor whose levels consist of several delimited strings into several factors
Description
Splits a factor
, whose levels
consist of strings delimited by a
separator character, into several factors
. It uses the function
strsplit
, with fixed = TRUE
to split the levels
.
Usage
fac.split(combined.factor, factor.names, sep=",", ...)
Arguments
combined.factor |
|
factor.names |
A |
sep |
A |
... |
Further arguments passed to the |
Value
A data.frame
containing the new factors
.
Author(s)
Chris Brien
See Also
fac.divide
, fac.uncombine
, fac.combine
in package dae and
strsplit
.
Examples
## Form a combined factor to split
data(Oats.dat)
tmp <- within(Oats.dat, Trts <- fac.combine(list(Variety, Nitrogen), combine.levels = TRUE))
##Variety levels sorted into alphabetical order
trts.dat <- fac.split(combined.factor = tmp$Trts,
factor.names = list(Variety = NULL, Nitrogen = NULL))
##Variety levels order from Oats.dat retained
trts.dat <- fac.split(combined.factor = tmp$Trts,
factor.names = list(Variety = levels(tmp$Variety), Nitrogen = NULL))