My codes are similar as follows:
output <- iris %>%
select(Sepal.Length, Sepal.Width, Species) %>%
filter(Sepal.Width < 3) %>%
group_by(Species) %>%
summarise( mean(Sepal.Length) ) %>%
print
# works as expected
# But when I want to write a function like this:
output_function <- function(a, b, c) {
out <- iris %>%
select(a, b, c) %>%
filter(b < 3) %>%
group_by(c) %>%
summarise( mean(a) )
return(out)
}
output_function(Sepal.Length, Sepal.Width, Species)
# does not work as expected
The reason is obvious, but I do not know how to solve it.
I do not know the variable types of the column variables when we use functions such as select, group_by, etc.
Thus, I do not know how to define correct parameters in this case so that they can be passed to the functions in dplyr.