if (FALSE) {
set.seed(567L)
df <- data.frame(gender= factor(sample(c("male", "female"), size= 100, replace= TRUE)),
age= factor(sample(1:5, size= 100, replace= TRUE)),
pov= factor(sample(c("lt_pov", "gt_eq_pov"),
size= 100, replace= TRUE, prob= c(.15,.85))),
p= runif(100))
df$p <- df$p / sum(df$p)
class(df) <- c("data.frame", "micro_synthetic")
# and example test elements
cond_v <- c("gender", "pov")
levels <- c("employed", "unemp", "not_in_LF")
sym_tbl <- data.frame(gender= rep(rep(c("male", "female"), each= 3), 2),
pov= rep(c("lt_pov", "gt_eq_pov"), each= 6),
cnts= c(52, 8, 268, 72, 12, 228, 1338, 93, 297, 921, 105, 554),
lvls= rep(levels, 4))
df_list <- replicate(10, df, simplify= FALSE)
st_list <- replicate(10, sym_tbl, simplify= FALSE)
# run
library(parallel)
syn <- all_geog_synthetic_new_attribute(df_list, prob_name= "p", attr_name= "variable",
conditional_vars= cond_v,st_list= st_list)
}
Run the code above in your browser using DataLab