I'm trying to compute mean after dropping high and low values. But the following ignores the trim parameter:
library(tidyverse)
mtcars %>%
summarize(mpg = mean(mpg),
mpg_trimmed = mean(mpg, trim = 0.05))
#> mpg mpg_trimmed
#> 1 20.09062 20.09062
But the following works:
library(tidyverse)
mtcars %>%
summarize(mpg = mean(.$mpg),
mpg_trimmed = mean(.$mpg, trim = 0.05))
#> mpg mpg_trimmed
#> 1 20.09062 19.95333
Why do I need to use .$?