View source: R/Ncontributors.R
Ncontributors | R Documentation |
Assuming aggregates are calculated via a dummy matrix by
z = t(x) %*% y
, the the number of unique contributing groups,
according to a grouping variable, are found for each aggregate.
The missing group category is not counted.
Ncontributors(x, groups)
x |
A (sparse) dummy matrix |
groups |
Vector of group categories |
Vector of numbers of unique groups
Øyvind Langsrud
ModelMatrix
library(SSBtools)
z <- SSBtoolsData("sprt_emp_withEU")
z$age[z$age == "Y15-29"] <- "young"
z$age[z$age == "Y30-64"] <- "old"
z$groups <- c("A", "A", "B", "A", "B", "C")
a <- ModelMatrix(z, formula = ~age*eu + geo + year, crossTable = TRUE)
cbind(as.data.frame(a$crossTable), nGroups = Ncontributors(a$modelMatrix, z$groups))
cbind(as.data.frame(a$crossTable), nYears = Ncontributors(a$modelMatrix, z$year))
cbind(as.data.frame(a$crossTable), nUnique_ths_per = Ncontributors(a$modelMatrix, z$ths_per))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.