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