Combining aes_string or aes_q with multiple column labels
<p>I am trying to combine labels using multiple columns with a flexible variable name used to color the labels in ggplot2.</p>

<p>I am able to do this with a hard-coded variable name "ret_cumarpu_cluster" in aes like this:</p>

<pre><code>ggplot(mergedata, aes(d2ret, d14cumarpu, col = ret_cumarpu_cluster)) +
    geom_point() +
    geom_text(aes(label=paste(device_bucket, d90installs), col = ret_cumarpu_cluster), hjust = -.15, show.legend = FALSE)
</code></pre>

<p>generating this graph:</p>

<p><a href="https://i.stack.imgur.com/WRNF1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WRNF1.png" alt="enter image description here"></a></p>

<p>However, I would like to replace the hard coded string "ret_cumarpu_cluster" with a string object cluster_type for generating multiple graphs. I've tried various iterations of aes_q and aes_string, but none seem to work very well with pasting the two column names together to generate a label. Ideally, my code would look something like:</p>

<pre><code>ggplot(mergedata, aes_string('d2ret', 'd14cumarpu', col = cluster_type)) +
    geom_point() +
    geom_text(aes_q(label=(paste(device_bucket, d90installs)), col = as.name(cluster_type)), hjust = -.15)
</code></pre>

<p>As I said, I can't quite get the paste to work with aes_q or aes_string to allow me to have a multiple column label.</p>

<p>As a workaround, I could obviously create a new column in the data frame pasting those two strings together and just use that, but I was wondering if this was possible. Thanks!</p>