Skip to contents

Creates a srvyr::tbl_svy object from a tbl_sample by first converting to a survey::svydesign() object via as_svydesign(), then wrapping with srvyr::as_survey_design().

Usage

# S3 method for class 'tbl_sample'
as_survey_design(.data, ...)

Arguments

.data

A tbl_sample object produced by execute().

...

Additional arguments passed to as_svydesign().

Value

A tbl_svy object from the srvyr package.

Details

This method is registered on the srvyr::as_survey_design() generic, so it is available when srvyr is loaded.

Random-size Poisson designs (bernoulli, pps_poisson) export to a pps survey design. These are summarised, grouped, and subset like any other srvyr design, with Horvitz-Thompson Poisson variances.

See also

as_svydesign() for converting to a survey.design2 object

Examples

library(srvyr)
#> 
#> Attaching package: ‘srvyr’
#> The following object is masked from ‘package:stats’:
#> 
#>     filter

sample <- sampling_design() |>
  stratify_by(region, alloc = "proportional") |>
  draw(n = 300) |>
  execute(bfa_eas, seed = 12345)

# Returns a tbl_svy for use with srvyr verbs
svy <- as_survey_design(sample)
svy |>
  group_by(region) |>
  summarise(mean_hh = survey_mean(households))
#> # A tibble: 13 × 3
#>    region            mean_hh mean_hh_se
#>    <fct>               <dbl>      <dbl>
#>  1 Boucle du Mouhoun    46.9      10.2 
#>  2 Cascades             40.1       7.35
#>  3 Centre              131.        7.98
#>  4 Centre-Est           66.8       8.35
#>  5 Centre-Nord          51.8       7.58
#>  6 Centre-Ouest         78.8      10.9 
#>  7 Centre-Sud          109.       15.7 
#>  8 Est                  52.1       6.53
#>  9 Hauts-Bassins        54.6       9.63
#> 10 Nord                 56.3       7.78
#> 11 Plateau-Central      68.6      11.7 
#> 12 Sahel                43.9      10.0 
#> 13 Sud-Ouest            58.8      15.5