I am trying to set a factor variable that gets called multiple times in a ggplot (e.g., color, factor). I have multiple variables I would like to factor by, and would like to avoid copying my code, and replacing that variable 4 times. If I wasn't plotting I would just use set the variable to
split <- data$npantc_quantile
and substitute it everywhere it appears.
gg_antc_q <- ggplot(data=filter(data, npantc_quantile %in% c(1, 5)),aes(x=delta,y=1-user_response, colour = npantc_quantile, group = npantc_quantile))+
stat_summary(fun.data = "mean_cl_boot", geom = "point", aes(shape = factor(npantc_quantile)), size = 4)+
stat_summary(fun.data = "mean_cl_boot", geom = "line")+
geom_smooth() +
ggtitle("Quantile Split: Arrows Normal") +
add_tone_lag_450
However, I know that I need to avoid dollar sign notation when calling anything inside aes(). How else could I call this split without having to rewrite it 4 times?