title: How to pass a point label to a ggplot scatterplot function in R?
body: <p>I've looked at many answers to  questions that are <em>almost</em> the same as this, but despite many experiments and alternative formulations, still haven't found one that works.
  The basic code for the scatterplot comes from Susanne E. Johnson’s &quot;A quick and easy function to plot lm() results with ggplot2 in R&quot; <a href="https://sejohnston.com/2012/08/09/" rel="nofollow noreferrer">https://sejohnston.com/2012/08/09/</a>. [Thanks Suzanne] That works perfectly. But I need to label the points in the plot. A current example, which crashes (Error: object 'car.name' not found) is this:</p>
  <pre><code>    ```
  ggplotRegression &lt;- function(fit) {
  require(ggplot2)
  ggplot(fit$model, aes_string(x = names(fit$model)[2], y = names(fit$model)[1])) +
  geom_point() +
  stat_smooth(method = &quot;lm&quot;, col = &quot;red&quot;) +
  `labs(title = paste(&quot;R2 = &quot;, signif(summary(fit)$r.squared, 4),             &quot;Intercept =&quot;,signif(fit$coef[[1]], 5),
  &quot; Slope =&quot;, signif(fit$coef[[2]], 5), 
  &quot; P =&quot;,signif(summary(fit)$coef[2, 4], 5)))`
  }
  temp &lt;- lm(mpg ~ wt, data = car)
  fit1&lt;- temp + geom_text (label = car.name)
  ggplotRegression(fit1)
      ```
  </code></pre>
  <p>I've tried placing the geom_text inside the function, etc. etc. but am not able to pass the variable label to the function. I'm sure it's extremely easy...but I just can't find it!
  Peter</p>