Is there a way to refer to other dataframe columns in a function that's called from summarise_all
, mutate_all
and similar?
Simple example:
summarise_all(mtcars, function(x) mean((x - mpg)/mpg))
# Error in (function (x) : object 'mpg' not found
summarise_all(mtcars, function(x) mean((x - .$mpg)/.$mpg))
# Error in (function (x) : object '.' not found
summarise_all(mtcars, function(x) mean((x - .x$mpg)/.x$mpg))
# Error in mean((x - .x$mpg)/.x$mpg) : object '.x' not found
This is with dplyr 0.8.3.