i trying generate list match required parameter rake
function in survey
package. parameter in question called sample.margins
, in documentation (page 27) it's described requiring list of formulas or data frames describing sample margins, must not contain missing values
i using following list:
[[1]] ~age_bucket <environment: 0x125f741c8> [[2]] ~educ_bucket
the list created as:
rake_sample_margins <- lapply(1:length(column_names), function(x) { as.formula(paste0("~", column_names)) }) rake_sample_margins[[length(rake_sample_margins) + 1]] <- as.formula(~educ_bucket)
so ~educ_bucket
created after lapply
whereas ~age_bucket
created iterating through column_names
vector (which in case contains string age_bucket
.
when run code using list parameter of rake function, error:
error in eval(expr, envir, enclos) : object 'educ_bucket' not found
even though when examine correlating dataframe in parameter indeed there (as 2nd element of list of data frames):
[[2]] educ_bucket freq 1: groupa .002 2: groupb .08
i've been told list of formulae must match column in data frame in list of dataframes passed, believe matching this. there else i'm missing? also, notice have irregularity list. first formula includes: <environment: 0x125f741c8>
underneath formula when printed out, whereas second not. what, if anything, mean?
Comments
Post a Comment