Sorry for the poorly worded question but I think this might be a common issue that I haven't found an answer for.
ggplot/dplyr don't use character types to call the column name to filter/group by:
library(dplyr)
library(ggplot2)
mtcars %>%
filter(gear > 4)
#OR
enter code here
ggplot(data = mtcars, aes(x = disp, y = wt, color = factor(gear))) + geom_point()
...so if wanted to build a function that would use these non-character types to say change gear to a different column, how would I do that? Do I need to call assign
?
Here's a hacky solution to filtering that may help clarify my question:
filter_foo <- function(data, column, value) {
data[column > value,]
}
filter_foo(mtcars, mtcars$gear , 4)