title: Capturing warning message into a variable in RR
body: <p>I have a function <code>draw_plot()</code> that takes in a data frame and other parameters(through the ellipsis) and simply returns a line plot.</p>
  <pre><code>draw_plot &lt;- function(data, ...){
    plot &lt;- ggplot(data = data, mapping = aes(x = x, y = y))
    plot &lt;- plot + do.call(&quot;geom_line&quot;, c(list(...)))
    return(plot)}
  
  
  data &lt;- tibble::tibble(x = c(1,2,3,4,5,6), y = c(5,6,7,8,9,10))
  draw_plot(data, test = 2, wrong = &quot;&quot;)
  </code></pre>
  <p>If I call the function as above, with parameters with key values which the <code>geom_line()</code> function doesn't recognize, it returns a warning saying 'Ignoring unknown parameters: test, wrong'.</p>
  <p>I am hoping to improve the function to facilitate more parameters, and other ggplot geoms. (ex: draw_plot(data, stat, ...)) The stat parameter will not be valid for <code>geom_line()</code>. Therefore I want to capture the original warning message and append 'stat' to it. ex: 'Ignoring unknown parameters: test, wrong, stat'</p>
  <p>To do this, is there any way that I can capture this particular warning message into a variable? p.s. I am trying to stick to base R to do this.</p>