1

I'm creating a plot using the forecast package- it includes the ability to generate a plot of a forecast generated with base plot.

I tried using recordPlot to save the plot to a variable, which allows me to recreate the plot in an interactive session. However, what I'd like to do (on a remote server) is generate the plot, save it to a variable and then include it as a mime_part when emailing it to myself using the sendmailR package.

The plot (named plt in the example below) does not show up in the email as it would if it were a ggplot2 object. Is there a way to send a base plot via sendmailR?

sendmail(from = email_from,
     to = email_to,
     subject = email_subject,
     msg=c(plt,
           email_body_text, "\n", "\n",
           mime_part(results, "query results", sep = ",", row.names = FALSE), "\n",
           "\n", "SQL query that generated this result:", "\n", "\n",
           query
     )
   )
Eric
  • 177
  • 1
  • 7
  • Please try providing a minimal reproducible example: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. – lukeA Aug 05 '15 at 08:01

1 Answers1

0

The answer, in case anyone stumbles across this post, seems to be "no". As of late 2015 you cannot email a base R plot without doing something like exporting it as a png or pdf and emailing that attachment.

Eric
  • 177
  • 1
  • 7
  • You might be able to encode it using base64 and then include it as an img tag in an html formatted email - but not as an attachement. Like what rmarkdown does on self-contained = TRUE. – Brandon Bertelsen Oct 02 '15 at 04:35