Convert a surveycore Design Object to a survey Package Design
Source:R/methods-conversion.R
as_svydesign.RdConverts a survey_taylor, survey_replicate, or survey_twophase object
to the corresponding survey package object: svydesign, svrepdesign,
or twophase. Useful for accessing survey package estimation functions
or for round-trip testing.
Value
A survey::svydesign, survey::svrepdesign, or survey::twophase
object.
Details
Metadata (variable labels, value labels) is NOT carried over — the survey
package has no metadata system.
See also
from_svydesign() to convert back from a survey design
Other conversion:
as_tbl_svy(),
from_svydesign(),
from_tbl_svy()
Examples
d <- as_survey(nhanes_2017, ids = sdmvpsu, weights = wtint2yr,
strata = sdmvstra, nest = TRUE)
if (requireNamespace("survey", quietly = TRUE)) {
sv <- as_svydesign(d)
survey::svymean(~ridageyr, sv, na.rm = TRUE)
}
#> mean SE
#> ridageyr 38.424 0.5244