View source: R/HierarchyCompute2.R
HierarchyCompute2 | R Documentation |
Extended variant of HierarchyCompute
with several column variables (not just "colFactor"
).
Parameter colVar splits the hierarchy variables in two groups and this variable overrides the difference between "rowFactor"
and "colFactor"
.
HierarchyCompute2(
data,
hierarchies,
valueVar,
colVar,
rowSelect = NULL,
colSelect = NULL,
select = NULL,
output = "data.frame",
...
)
data |
The input data frame |
hierarchies |
A named list with hierarchies |
valueVar |
Name of the variable(s) to be aggregated |
colVar |
Name of the column variable(s) |
rowSelect |
Data frame specifying variable combinations for output |
colSelect |
Data frame specifying variable combinations for output |
select |
Data frame specifying variable combinations for output |
output |
One of "data.frame" (default), "outputMatrix", "matrixComponents". |
... |
Further parameters sent to |
Within this function, HierarchyCompute
is called two times.
By specifying output as "matrixComponents"
,
output from the two runs are retuned as a list with elements hcRow
and hcCol
.
The matrix multiplication in HierarchyCompute is extended to
outputMatrix
=
hcRow$dataDummyHierarchy
%*%
hcRow$valueMatrix
%*%
t(hcCol$dataDummyHierarchy)
.
This is modified in cases with more than a single valueVar
.
As specified by the parameter output
There is no need to call HierarchyCompute2
directly.
The main function HierarchyCompute
can be used instead.
Øyvind Langsrud
Hierarchies2ModelMatrix
, AutoHierarchies
.
x <- SSBtoolsData("sprt_emp")
geoHier <- SSBtoolsData("sprt_emp_geoHier")
ageHier <- SSBtoolsData("sprt_emp_ageHier")
HierarchyCompute(x, list(age = ageHier, geo = geoHier, year = "rowFactor"), "ths_per",
colVar = c("age", "year"))
HierarchyCompute(x, list(age = ageHier, geo = geoHier, year = "rowFactor"), "ths_per",
colVar = c("age", "geo"))
HierarchyCompute(x, list(age = ageHier, geo = geoHier, year = "rowFactor"), "ths_per",
colVar = c("age", "year"), output = "matrixComponents")
HierarchyCompute(x, list(age = ageHier, geo = geoHier, year = "rowFactor"), "ths_per",
colVar = c("age", "geo"), output = "matrixComponents")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.