View source: R/HierarchyCompute.R
HierarchyFix | R Documentation |
Make sure that variable names and sign coding follow an internal standard. Level may be computed automatically
HierarchyFix(
hierarchy,
hierarchyVarNames = c(mapsFrom = "mapsFrom", mapsTo = "mapsTo", sign = "sign", level =
"level"),
autoLevel = TRUE
)
hierarchy |
data frame with hierarchy table |
hierarchyVarNames |
variable names |
autoLevel |
When TRUE, level is computed by automatic method |
data frame with hierarchy table
Øyvind Langsrud
# Make input data by changing variable names and sign coding.
h <- SSBtoolsData("FIFA2018ABCD")[, 1:3]
names(h)[1:2] <- c("from", "to")
minus <- h$sign < 0
h$sign <- "+"
h$sign[minus] <- "-"
# Run HierarchyFix - Two levels created
HierarchyFix(h, c(mapsFrom = "from", mapsTo = "to", sign = "sign"))
# Extend the hierarchy table
h2 <- rbind(data.frame(from = c("Oceania", "Asia", "Africa", "America", "Europe"),
to = "World", sign = "+"),
data.frame(from = c("World", "Europe"),
to = "nonEurope", sign = c("+", "-")), h)
# Run HierarchyFix - Three levels created
HierarchyFix(h2, c(mapsFrom = "from", mapsTo = "to", sign = "sign"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.