Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unfortunately, Rmarkdown is not directly supported in emails, since emails typically use HTML as its markup language. However, there are a couple of workarounds you can try to include your Rmarkdown content as text or an attachment in your email.

Option 1: Convert Rmarkdown to Plain Text You can convert your Rmarkdown document to plain text using the ‘knitr’ package in R. Once you have the plain text file, you can copy and paste the content into your email body. However, keep in mind that you will lose any formatting, images, or code chunks in the process.

Option 2: Convert Rmarkdown to PDF Another option is to convert your Rmarkdown document to a PDF using the ‘rmarkdown’ package in R. You can then attach the PDF in your email and provide a brief explanation of its content in the body of the email. This way, your recipients can still see the formatted text, images, and code chunks in the PDF.

Here's an example of how to convert Rmarkdown to PDF in R:

{r} library(rmarkdown) render("your-rmarkdown-file.Rmd", "pdf_document")

Once the PDF is generated, you can attach it to your email by selecting ‘Attach file’ in Outlook and choosing the PDF file.

Overall, while there isn't a perfect solution for including Rmarkdown in emails, these workarounds should allow you to share your Rmarkdown documents with others.