Introduction to the

The first installment of the communication documentation series is how to make Rbeamer using Rmarkdown. Today, let’s introduce another form of document communication: how to use Rmarkdown to create a customized PPT!

Using the tutorial

Note: This output format is only available in RmarkDown > = V1.9, and Pandoc requires at least V2.0.5. You can check the version of the rmarkDown package and Pandoc using packageVersion (‘rmarkdown’) and rmarkdown :: pandoc_version () in R, respectively.

    1. Open New File -r markdown and select PowerPoint

It is recommended to create a new project and then regenerate the corresponding Rmarkdown file in this project.

    1. Click on the icon knitr to get the PPT of the template

Custom Templates

You can customize the look of a PowerPoint presentation by passing in a custom reference document via the reference_doc option, for example:

---
title: "Habits"
output:
  powerpoint_presentation:
    reference_doc: my-styles.pptx
---
Copy the code

Note that the reference_doc option requires an rMarkDown version later than 1.9:

If (packageVersion('rmarkdown') <= '1.9') {install. Packages ('rmarkdown') # update rmarkdown from CRAN}Copy the code

Basically, any template included in the newer versions of Microsoft PowerPoint will work. You can create a new *.pptx file template and use it as a reference document (template). Pandoc will read the styles in the template and apply them to the PowerPoint presentation created from R Markdown.

You can directly use Microsoft PowerPoint official free templates.

The specific sample

Xiaobian made a Alma mater PPT cover as a custom reference template for your reference.

Note: the wzu.pptx file is in the same folder as.rmd (I only put one page of wzu.pptx file here)

The yamL file is as follows:

-- title: "reference_doc: wzo.pptx" author: "reference_doc" date: "' R sys. date () '" output: powerpoint_presentation: reference_doc: wzO.pptx --Copy the code

Finally, the PPT obtained by Rmarkdown can contain formulas, pictures, codes and output results.

Xiaobian has something to say

  • This is just a basic introduction. I won’t talk too much about literature insertion, code output size, image output size, etc. For details, please refer to Xie Yihui’s R Markdown: The Definitive Guide. I’ll try to write a tutorial on these techniques later.

  • The advantage of POWERPOINT over Rbeamer is that the template can be customized, which is more personal, and the output can be manually adjusted.

  • Interested friends can make their own templates, Rmarkdown more powerful document communication is still to come, enjoy the series!