Learn R Programming

surveycore (version 0.8.3)

remove_survey: Remove Surveys from a survey_collection

Description

Drops one or more named surveys from a collection and returns a new survey_collection. Errors if any requested name is not present.

Usage

remove_survey(x, name)

Value

A new survey_collection without the dropped surveys. Errors surveycore_error_collection_empty if removing would leave the collection empty.

Arguments

x

A survey_collection.

name

Character vector of survey names to drop. All names must be present in names(x).

See Also

as_survey_collection(), add_survey()

Other collections: add_survey(), as_survey_collection(), set_collection_id(), set_collection_if_missing_var(), survey_collection()

Examples

Run this code
d1 <- as_survey(gss_2024, ids = vpsu, weights = wtssps,
                strata = vstrat, nest = TRUE)
d2 <- as_survey(gss_2024, ids = vpsu, weights = wtssps,
                strata = vstrat, nest = TRUE)
coll <- as_survey_collection(a = d1, b = d2)
coll2 <- remove_survey(coll, "a")
names(coll2)

Run the code above in your browser using DataLab