Hi
Sorry if this has already been addressed, but I coudn't find the topic anywere.
It looks like if you use the function mean
and set the trim
argument to a value greater than 0 inside summarise
, the output is the same as with the regular arithmetic mean.
If I take the mpg
column from the mtcars data.frame
and compute the two means separately I obtain this
mean(mtcars$mpg)
[1] 20.09062
mean(mtcars$mpg, trim = 0.3)
[1] 19.17857
Whereas if I do it with summarise
it gives this result
mtcars %>%
summarise(mpg = mean(mpg), mpg_trimmed = mean(mpg, trim = 0.3))
mpg mpg_trimmed
20.09062 20.09062
Am I doing something wrong? Is there something I'm not getting about how the trim argument works?
Thanks