# Examples from ?survey::svrepdesign()
library(survey)
library(dplyr)
data(scd)
# use BRR replicate weights from Levy and Lemeshow
scd <- scd %>%
mutate(rep1 = 2 * c(1, 0, 1, 0, 1, 0),
rep2 = 2 * c(1, 0, 0, 1, 0, 1),
rep3 = 2 * c(0, 1, 1, 0, 0, 1),
rep4 = 2 * c(0, 1, 0, 1, 1, 0))
scdrep <- scd %>%
as_survey_rep(type = "BRR", repweights = starts_with("rep"),
combined_weights = FALSE)
# as_survey_rep_ uses standard evaluation
repwts <- names(scd)[grep("^rep", names(scd))]
scdrep <- scd %>%
as_survey_rep_(type = "BRR", repweights = repwts,
combined_weights = FALSE)Run the code above in your browser using DataLab