title: Adding italicised r with correlation coefficient to a scatter plot chart in ggplot
body: <p>I'm trying to use the code below to generate a simple scatter plot with a correlation coefficient that would have italicised <em>r</em> placed on the plot.</p>
  
  <pre><code>data(mtcars)
  
  # Load required libraries
  require(ggplot2)               # To derive the graphs
  require(ggthemes)              # To apply ggplot themes to the chart
  require(scales)                # For pretty breaks
  
  # Function to generate correlation coefficient for the charts
  corr_eqn &lt;- function(x,y, digits = 2) {
    corr_coef &lt;- round(cor(x, y), digits = digits)
    corr_coef &lt;- expression(paste(italic(r)," = ", corr_coef))
    return(corr_coef)
  }
  
  # Provide a scatter plot for income and health deprivation
  ggplot(mtcars, aes(x = drat, y = wt)) +
    geom_point(shape = 19, size = 2, aes(colour = as.factor(cyl))) +
    geom_smooth(colour = "red", fill = "lightgreen", method = 'lm') +
    ggtitle("Example") +
    xlab("drat") +
    ylab("wt") +
    scale_colour_tableau("tableau10") +
    geom_text(x = 3, y = 3,
              label = corr_eqn(mtcars$drat,
                               mtcars$wt), parse = TRUE) +
    theme(legend.key = element_blank(),
          legend.background = element_rect(colour = 'black'),
          legend.position = "bottom",
          legend.title = element_blank(),
          plot.title = element_text(lineheight = .8, face = "bold", vjust = 1),
          axis.text.x = element_text(size = 11, vjust = 0.5,
                                     hjust = 1, colour = 'black'),
          axis.text.y = element_text(size = 11, colour = 'black'),
          axis.title = element_text(size = 10, face = 'bold'),
          axis.line = element_line(colour = "black"),
          plot.background = element_rect(colour = 'black', size = 1),
          panel.background = element_blank())
  </code></pre>
  
  <p>The code stops with the <code>?</code> mark in console. Running the code with the lines:</p>
  
  <pre><code>#   geom_text(x = 3, y = 3,
  #             label = corr_eqn(mtcars$drat, mtcars$wt), parse = TRUE) +
  </code></pre>
  
  <p>commented, generates the following chart:
  <img src="https://i.stack.imgur.com/ITJi5.png" alt="scatter plot"></p>
  
  <p>I'm guessing that my function to generate equation of the format <em>r</em> = 0.7 does not work, how can I fix it?</p>