| Extend0_n_rnd_groups | R Documentation |
Extend0_with_n_rnd_groups is a function that calls Extend0() with
Extend0_n_rnd_groups() as the varGroups attribute.
The data are extended in the usual way based on some of the varGroups
elements. For the remaining elements, combinations are sampled.
Extend0_n_rnd_groups(
data,
varGroups,
n_rnd_groups = 0,
rnd_rep = 1,
rndSeed = 123
)
Extend0_with_n_rnd_groups(data, varGroups, non_rnd, rnd_rep = 1, rndSeed = 123)
data |
data.frame within |
varGroups |
argument to |
n_rnd_groups |
The last |
rnd_rep |
When |
rndSeed |
Internal random seed to be used |
non_rnd |
In |
A data frame.
Extend0rnd1()
# Data to be extended
d <- SSBtoolsData("barcelona2025")[c(3, 6, 12, 18), -5]
rownames(d) <- NULL
d$year <- 2025:2026
d$month <- c("January", rep("August", 3))
d
# varGroups as a named list
varGroups <- list(geo = c("country", "city"),
age = "age",
sex = "sex",
time = c("month", "year"))
a0 <- Extend0(d, varGroups = varGroups)
dim(a0) # all combinations, 48 rows
a1 <- Extend0_with_n_rnd_groups(d, varGroups = varGroups, non_rnd = c("time", "geo"))
a1
dim(unique(a1[c("month", "year", "country", "city")])) # all combinations of time and geo
unique(a1[c("sex", "month", "year")]) # not all combinations
a2 <- Extend0_with_n_rnd_groups(d, varGroups = varGroups, non_rnd = c("sex", "time", "geo"))
dim(a2)
# all combinations of selected variables
dim(unique(a2[c("sex", "month", "year", "country", "city")]))
# not all combinations of selected variables
dim(unique(a2[c("age", "month", "year", "country", "city")]))
# effect of rnd_rep
for (rnd_rep in c(1, 2, 3, 5, 10, 50))
print(dim(Extend0_with_n_rnd_groups(d,
varGroups = varGroups, non_rnd = c("time", "geo"), rnd_rep = rnd_rep)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.