fac.split | R Documentation |
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
.
fac.split(combined.factor, factor.names, sep=",", ...)
combined.factor |
A |
factor.names |
A |
sep |
A |
... |
Further arguments passed to the |
A data.frame
containing the new factors
.
Chris Brien
fac.divide
, fac.uncombine
, fac.combine
in package dae and
strsplit
.
## 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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.