Aesthetic mappings describe how variables in the data are mapped to visualproperties (aesthetics) of geoms.aes() uses non-standardevaluation to capture the variable names.aes_() andaes_string()require you to explicitly quote the inputs either with"" foraes_string(), or withquote or~ foraes_().(aes_q() is an alias toaes_()). This makesaes_() andaes_string() easy to program with.
aes_string() andaes_() are particularly useful when writingfunctions that create plots because you can use strings or quotednames/calls to define the aesthetic mappings, rather than having to usesubstitute() to generate a call toaes().
I recommend usingaes_(), because creating the equivalents ofaes(colour = "my colour") oraes(x = `X$1`)withaes_string() is quite clunky.
Life cycle
All these functions are deprecated. Please use tidy evaluation idiomsinstead. Regardingaes_string(), you can replace it with.data pronoun.For example, the following code can achieve the same mapping asaes_string(x_var, y_var).
x_var<-"foo"y_var<-"bar"aes(.data[[x_var]],.data[[y_var]])For more details, please seevignette("ggplot2-in-packages").
