z <- SSBtoolsData("sprt_emp_withEU")[-(1:3), ]
z$age[z$age == "Y15-29"] <- "young"
z$age[z$age == "Y30-64"] <- "old"
hi <- SSBtools::FindHierarchies(z[, -4])
inputInOutput <- c(TRUE, FALSE, FALSE)
mm <- SSBtools::ModelMatrix(z, hi, crossTable = TRUE, inputInOutput = inputInOutput)
out <- HierarchyContributors(z, mm$modelMatrix, mm$crossTable, hi, inputInOutput)
# The nonzero values are caused by the removed three data rows
cbind(mm$crossTable, out$max - out$min)
cbind(mm$crossTable, out$ac - out$n)
Run the code above in your browser using DataLab