Learn R Programming

surveycore (version 0.8.3)

as_svydesign: Convert a surveycore Design Object to a survey Package Design

Description

Converts 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.

Usage

as_svydesign(x)

Value

A survey::svydesign, survey::svrepdesign, or survey::twophase

object.

Arguments

x

A survey_taylor, survey_replicate, 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

Run this code
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)
}

Run the code above in your browser using DataLab