fac.split {dae}R Documentation

Splits a factor whose levels consist of several delimited strings into several factors


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=",", ...)



A factor to be split into several factors.


A list of names for factors and associated levels, if required. The names of the componeonts of the list are used for the names of the new factors. Each component of the list should either be NULL or a vector of levels for the new factor. If a component is NULL then the unique values for the supplied factor are used as the levels, which are sorted into alphabetical order. If a either a numeric or a character vector is supplied for a component, then these are supplied as the levels of the new factor.


A character string that separates the levels in the combined.factor.


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


A data.frame containing the new factors.


Chris Brien

See Also

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


## Forma combined factor to split
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))

[Package dae version 3.2.19 Index]