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().
Arguments
- .data
A
tbl_sampleobject produced byexecute().- ...
Additional arguments passed to
as_svydesign().
Details
This method is registered on the srvyr::as_survey_design() generic,
so it is available when srvyr is loaded.
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 = 42)
# 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 173. 17.1
#> 2 Cascades 148. 10.4
#> 3 Centre 357. 17.9
#> 4 Centre-Est 225. 14.5
#> 5 Centre-Nord 195. 17.8
#> 6 Centre-Ouest 225. 21.3
#> 7 Centre-Sud 214. 12.2
#> 8 Est 151. 8.93
#> 9 Hauts-Bassins 213. 19.1
#> 10 Nord 172. 16.4
#> 11 Plateau-Central 189. 12.5
#> 12 Sahel 182. 10.5
#> 13 Sud-Ouest 177. 12.8