df1 <- mtcars %>%
group_by(gear) %>%
summarise(Mittelwert = mean(mpg, na.rm = TRUE))
df1
df2 <- mtcars %>%
group_by(mtcars[[10]]) %>%
summarise(Mittelwert = mean(mtcars[[1]]), na.rm = TRUE)
df2
The last code gives me the mean of the whole data.frame. Since this code is used in a loop, i need to use brackets. Can you help me to get a dynamic code with valid results?