HierarchyFix: Change the hierarchy table to follow the standard

Description Usage Arguments Value Author(s) Examples

View source: R/HierarchyCompute.R

Description

Make sure that variable names and sign coding follow an internal standard. Level may be computed automatically

Usage

1
2
HierarchyFix(hierarchy, hierarchyVarNames = c(mapsFrom = "mapsFrom",
  mapsTo = "mapsTo", sign = "sign", level = "level"), autoLevel = TRUE)

Arguments

hierarchy

data frame with hierarchy table

hierarchyVarNames

variable names

autoLevel

When TRUE, level is computed by automatic method

Value

data frame with hierarchy table

Author(s)

Øyvind Langsrud

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# 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"))

statisticsnorway/SSBtools documentation built on Feb. 17, 2020, 7:07 p.m.