Trouble with an R function for making a ggplot2 graph and optionally facetting with user-specified columns
This works:
myplot_facet <- function(DF, colorBy, facetBy){
facetBy <- enquo(facetBy)
ggplot(DF, aes(x = price, y = carat, color = {{colorBy}} )) +
geom_point() +
facet_wrap(vars(!!facetBy))
}
myplot_facet(diamonds, colorBy = cut, facetBy = color)