I can't figure out how to loop when there is data masking going on (aka, it is trying to recognize my looping variable as a column in the dataset.
The current issue is that {{var_i}} is printing as "age" but the group_by needs it to be just age
test <- c("age", "year")
for (var_i in test) {
df_explore <- df %>%
group_by( {{var_i}} ) %>%
summarize(rate = sum(y) / sum(x))
ggplot(df_explore, aes(x = {{var_i}}, y = rate) +
geom_line() +
labs(x = {{var_i}}, y = "Rate")
}