You must specify a survey before the other functions, such as tab()
,
will work. To convert a data.frame
to a survey object, see survey::svydesign()
or survey::svrepdesign()
.
Usage
set_survey(design, csv = getOption("surveytable.csv"), ...)
Arguments
- design
either a survey object (created with
survey::svydesign()
orsurvey::svrepdesign()
); or, for an unweighted survey, adata.frame
.- csv
name of a CSV file
- ...
arguments to
set_opts()
.
Details
Optionally, the survey can have an attribute called label
, which is the
long name of the survey. Optionally, each variable in the survey can have an
attribute called label
, which is the variable's long name.
See also
Other options:
set_opts()
,
show_options()
,
surveytable-options
Examples
set_survey(namcs2019sv)
#> Survey info {NAMCS 2019 PUF}
#> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
#> │ Variables │ Observations │ Design │
#> ├───────────┼──────────────┼────────────────────────────────────────────────┤
#> │ 33 │ 8,250 │ Stratified 1 - level Cluster Sampling design │
#> │ │ │ (with replacement) │
#> │ │ │ With (398) clusters. │
#> │ │ │ namcs2019sv = survey::svydesign(ids = ~CPSUM, │
#> │ │ │ strata = ~CSTRATM, weights = ~PATWT │
#> │ │ │ , data = namcs2019sv_df) │
#> └───────────┴──────────────┴────────────────────────────────────────────────┘
#>
set_survey(namcs2019sv, mode = "general")
#> * Mode: General.
#> Survey info {NAMCS 2019 PUF}
#> ┌───────────┬──────────────┬────────────────────────────────────────────────┐
#> │ Variables │ Observations │ Design │
#> ├───────────┼──────────────┼────────────────────────────────────────────────┤
#> │ 33 │ 8,250 │ Stratified 1 - level Cluster Sampling design │
#> │ │ │ (with replacement) │
#> │ │ │ With (398) clusters. │
#> │ │ │ namcs2019sv = survey::svydesign(ids = ~CPSUM, │
#> │ │ │ strata = ~CSTRATM, weights = ~PATWT │
#> │ │ │ , data = namcs2019sv_df) │
#> └───────────┴──────────────┴────────────────────────────────────────────────┘
#>