{emayili} Rendering R Markdown
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
In a previous post I documented a new feature in {emayili}
, the ability to render Plain Markdown directly into the body of an email message.
Today I’m announcing the release of a new minor version, 0.5.0, in which {emayili}
is now able to render R Markdown into an email. This is a major leap forward for the package.
I should mention that this capability (rendering R Markdown into an email) is already available in the {mailmerge}
package, but that only works with Gmail.
Install & Load
You can install this version directly from GitHub as follows.
remotes::install_github("datawookie/emayili", ref = "v0.5.0")
This version was also published on CRAN on 17 September 2021.
Now load the package.
library(emayili) # A couple of options to display message body. # options( envelope_details = TRUE, envelope_invisible = FALSE )
Check on the installed version.
packageVersion("emayili") [1] '0.5.0'
A Simple R Markdown File
For the purposes of illustration let’s use a super simple R Markdown file, pi.Rmd
.
--- title: "Approximating Pi" output: html_document --- ```{r} 22 / 7 ```
Create an empty message object.
msg <- envelope()
And then render pi.Rmd
into the body of the message. In this case I’m going to set the include_css
option to FALSE
so that the copious volume of CSS is suppressed in the resulting HTML.
msg %>% render("pi.Rmd", include_css = FALSE) Date: Fri, 17 Sep 2021 10:16:09 GMT X-Mailer: {emayili}-0.5.0 MIME-Version: 1.0 Content-Type: multipart/related; boundary="b9173ea5" --b9173ea5 Content-Type: text/html; charset=utf-8 Content-Disposition: inline <html><body> <div class="container-fluid main-container"> <div id="header"> <h1 class="title toc-ignore">Approximating Pi</h1> </div> <pre class="r"><code>22 / 7</code> <code>[1] 3.142857</code>