Hierarchy2Formula {SSBtools} | R Documentation |
Hierarchy2Formula
Description
Conversion between to-from coded hierarchy and formulas written with =, - and +.
Usage
Hierarchy2Formula(
x,
hierarchyVarNames = c(mapsFrom = "mapsFrom", mapsTo = "mapsTo", sign = "sign", level =
"level")
)
Formula2Hierarchy(s)
Hierarchies2Formulas(x, ...)
Arguments
x |
Data frame with to-from coded hierarchy |
hierarchyVarNames |
Variable names in the hierarchy tables as in |
s |
Character vector of formulas written with =, - and +. |
... |
Extra parameters. Only |
Value
See Arguments
Note
Hierarchies2Formulas
is a wrapper for lapply(x, Hierarchy2Formula, ...)
Author(s)
Øyvind Langsrud
See Also
DimList2Hierarchy
, DimList2Hrc
, AutoHierarchies
.
Examples
x <- SSBtoolsData("sprt_emp_geoHier")
s <- Hierarchy2Formula(x)
s
Formula2Hierarchy(s)
# Demonstrate Hierarchies2Formulas and problems
hi <- FindHierarchies(SSBtoolsData("sprt_emp_withEU")[, c("geo", "eu", "age")])
hi
Hierarchies2Formulas(hi) # problematic formula since minus sign in coding
AutoHierarchies(Hierarchies2Formulas(hi)) # Not same as hi because of problems
# Change coding to avoid problems
hi$age$mapsFrom <- gsub("-", "_", hi$age$mapsFrom)
hi
Hierarchies2Formulas(hi)
AutoHierarchies(Hierarchies2Formulas(hi))
[Package SSBtools version 1.5.2 Index]