I need to run ggplot in a function. The input data.frame/tibble passed to the function has special characters (white spaces, commas etc.) in the columns with data to be plotted. The column names to be plotted are passed as arguments to the function. Here is a working example, both aes_ and aes_string fail, but for different reasons. Help appreciated
trial.tbl_df <- tibble(a = 1:3, `complex, `=4:6)
plotfunc <- function(tbl2plot,yvar){
ggplot(tbl2plot,aes_(x = "a", y = yvar )) +
geom_point()
}
plotfunc(tbl2plot = trial.tbl_df, yvar = `complex, `)