Having trouble with the fpc in srvyr -
baro_weightedpointcoverage_srvyr <- df_child_level_baro_point_coverage %>%
as_survey_design(ids=grappe_no,fpc=~fpc, weights=~HH_weight)
Error: Formula shorthand must be wrapped in where()
.
Having trouble with the fpc in srvyr -
baro_weightedpointcoverage_srvyr <- df_child_level_baro_point_coverage %>%
as_survey_design(ids=grappe_no,fpc=~fpc, weights=~HH_weight)
Error: Formula shorthand must be wrapped in where()
.
You don't need the tildes (~). See example below with data from the survey package:
library(survey)
#> Loading required package: grid
#> Loading required package: Matrix
#> Loading required package: survival
#>
#> Attaching package: 'survey'
#> The following object is masked from 'package:graphics':
#>
#> dotchart
library(srvyr)
#>
#> Attaching package: 'srvyr'
#> The following object is masked from 'package:stats':
#>
#> filter
data(api)
dclus1 <- apiclus1 %>%
as_survey_design(ids=dnum, weights = pw, fpc = fpc)
dclus1_yourexample <- apiclus1 %>%
as_survey_design(ids=dnum, weights = ~pw, fpc = ~fpc)
#> Error: Formula shorthand must be wrapped in `where()`.
#>
#> # Bad
#> data %>% select(~fpc)
#>
#> # Good
#> data %>% select(where(~fpc))
Created on 2021-11-23 by the reprex package (v2.0.1)
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.