0

I want to ask related, how to estimate an indicator using the srvyr package in a loop. where only the variable changes. I have a data set df with variables sp1 and sp2 which will be grouped by urban and rural.

I've tried it with a syntax like this

map(
 x = c("sp1", "sp2"), 
 .f = function(x)
   df %>%
   group_by_at(vars("class")) %>%
   summarise(
     prop = survey_mean(.x)
   )
)

but I get an error like this,

Error in map(x = c("sp1", "sp2"), .f = function(x) df %>% group_by_at(vars("class")) %>%  : 
  argument ".x" is missing, with no default

can anyone help my problem, thank you

  • 1
    just a hint: `x != .x` – D.J Mar 08 '22 at 06:03
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Mar 08 '22 at 07:02

0 Answers0