Skip to contents

Subset a survey, while preserving variable labels

Usage

survey_subset(design, subset, label)

Arguments

design

a survey object

subset

an expression specifying the sub-population

label

survey label of the newly created survey object

Value

a new survey object

Examples

children = survey_subset(namcs2019sv, AGE < 18, "Children < 18")
set_survey(children)
#>                          Survey info {Children < 18}                         
#> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
#> │ Variables │ Observations │ Design                                         │
#> ├───────────┼──────────────┼────────────────────────────────────────────────┤
#> │        33 │        1,066 │ Stratified 1 - level Cluster Sampling design   │
#> │           │              │ (with replacement)                             │
#> │           │              │ With (139) clusters.                           │
#> │           │              │ survey_subset(namcs2019sv, AGE < 18, "Children │
#> │           │              │ < 18")                                         │
#> └───────────┴──────────────┴────────────────────────────────────────────────┘
#> 
tab("AGER")
#>                          Patient age recode (knowns only) {Children < 18}                         
#> ┌─────────────┬─────┬─────────────┬──────────┬──────────┬──────────┬─────────┬─────┬──────┬──────┐
#> │ Level       │   n │      Number │ SE (000) │ LL (000) │ UL (000) │ Percent │  SE │   LL │   UL │
#> │             │     │       (000) │          │          │          │         │     │      │      │
#> ├─────────────┼─────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ Under 15    │ 887 │     117,917 │   14,097 │   93,229 │  149,142 │    86.1 │ 1.6 │ 82.5 │ 89.2 │
#> │ years       │     │             │          │          │          │         │     │      │      │
#> ├─────────────┼─────┼─────────────┼──────────┼──────────┼──────────┼─────────┼─────┼──────┼──────┤
#> │ 15-24 years │ 179 │      19,004 │    2,872 │   14,051 │   25,702 │    13.9 │ 1.6 │ 10.8 │ 17.5 │
#> └─────────────┴─────┴─────────────┴──────────┴──────────┴──────────┴─────────┴─────┴──────┴──────┘
#>   N = 1066. Checked NCHS presentation standards. Nothing to report.                               
#>