Rmarkdown Powerpoint



R Markdown is a package (as well as an ecosystem of tools) that allows us to add R code to a plain-text file with some Markdown formatting. The document can then be rendered into many different output formats including PDF, HTML, Microsoft Word, and Microsoft PowerPoint. Markdown is a simple language to write web-based content easy both for writing and reading. The key is that it can be converted to many output formats with a simplified syntax. Format for converting from R Markdown to an MS PowerPoint document. The function will allow you to specify the destination of your chunks in the output PowerPoint file. In this case, you must specify the layout and master for the layout you want to use, as well as the ph argument, which will allow you to specify the placeholder to be generated to place the result.

  1. Rmarkdown Powerpoint Presentation
  2. Rmarkdown Powerpoint Tables
  3. R Markdown Powerpoint
  4. Rmarkdown Powerpoint Theme
  1. A question was previously asked on how to indent text without a bullet point in RMarkdown, but this was for HTML output: Indent without adding a.
  2. PowerPoint presentation. To create a PowerPoint presentation from R Markdown, you specify the powerpointpresentation output format in the YAML metadata of your document. Please note that this output format is only available in rmarkdown = v1.9, and requires at least Pandoc v2.0.5.

29.1 Introduction

So far you’ve seen R Markdown used to produce HTML documents. This chapter gives a brief overview of some of the many other types of output you can produce with R Markdown. There are two ways to set the output of a document:

  1. Permanently, by modifying the YAML header:

  2. Transiently, by calling rmarkdown::render() by hand:

    This is useful if you want to programmatically produce multiple types ofoutput.

Rmarkdown Powerpoint

RStudio’s knit button renders a file to the first format listed in its output field. You can render to additional formats by clicking the dropdown menu beside the knit button.

29.2 Output options

R to powerpoint

Each output format is associated with an R function. You can either write foo or pkg::foo. If you omit pkg, the default is assumed to be rmarkdown. It’s important to know the name of the function that makes the output because that’s where you get help. For example, to figure out what parameters you can set with html_document, look at ?rmarkdown::html_document.

To override the default parameter values, you need to use an expanded output field. For example, if you wanted to render an html_document with a floating table of contents, you’d use:

You can even render to multiple outputs by supplying a list of formats:

Note the special syntax if you don’t want to override any of the default options.

29.3 Documents

The previous chapter focused on the default html_document output. There are a number of basic variations on that theme, generating different types of documents:

  • pdf_document makes a PDF with LaTeX (an open source document layoutsystem), which you’ll need to install. RStudio will prompt you if youdon’t already have it.

  • word_document for Microsoft Word documents (.docx).

  • odt_document for OpenDocument Text documents (.odt).

  • rtf_document for Rich Text Format (.rtf) documents.

  • md_document for a Markdown document. This isn’t typically useful byitself, but you might use it if, for example, your corporate CMS orlab wiki uses markdown.

  • github_document: this is a tailored version of md_documentdesigned for sharing on GitHub.

Remember, when generating a document to share with decision makers, you can turn off the default display of code by setting global options in the setup chunk:

For html_documents another option is to make the code chunks hidden by default, but visible with a click:

29.4 Notebooks

A notebook, html_notebook, is a variation on a html_document. The rendered outputs are very similar, but the purpose is different. A html_document is focused on communicating with decision makers, while a notebook is focused on collaborating with other data scientists. These different purposes lead to using the HTML output in different ways. Both HTML outputs will contain the fully rendered output, but the notebook also contains the full source code. That means you can use the .nb.html generated by the notebook in two ways:

  1. You can view it in a web browser, and see the rendered output. Unlikehtml_document, this rendering always includes an embedded copy ofthe source code that generated it.

  2. You can edit it in RStudio. When you open an .nb.html file, RStudio willautomatically recreate the .Rmd file that generated it. In the future, youwill also be able to include supporting files (e.g. .csv data files), whichwill be automatically extracted when needed.

Presentation

Emailing .nb.html files is a simple way to share analyses with your colleagues. But things will get painful as soon as they want to make changes. If this starts to happen, it’s a good time to learn Git and GitHub. Learning Git and GitHub is definitely painful at first, but the collaboration payoff is huge. As mentioned earlier, Git and GitHub are outside the scope of the book, but there’s one tip that’s useful if you’re already using them: use both html_notebook and github_document outputs:

html_notebook gives you a local preview, and a file that you can share via email. github_document creates a minimal md file that you can check into git. You can easily see how the results of your analysis (not just the code) change over time, and GitHub will render it for you nicely online.

29.5 Presentations

You can also use R Markdown to produce presentations. You get less visual control than with a tool like Keynote or PowerPoint, but automatically inserting the results of your R code into a presentation can save a huge amount of time. Presentations work by dividing your content into slides, with a new slide beginning at each first (#) or second (##) level header. You can also insert a horizontal rule (***) to create a new slide without a header.

R Markdown comes with three presentation formats built-in:

  1. ioslides_presentation - HTML presentation with ioslides

  2. slidy_presentation - HTML presentation with W3C Slidy

  3. beamer_presentation - PDF presentation with LaTeX Beamer.

Two other popular formats are provided by packages:

  1. revealjs::revealjs_presentation - HTML presentation with reveal.js.Requires the revealjs package.

  2. rmdshower, https://github.com/MangoTheCat/rmdshower, provides awrapper around the shower, https://github.com/shower/shower,presentation engine

29.6 Dashboards

Dashboards are a useful way to communicate large amounts of information visually and quickly. Flexdashboard makes it particularly easy to create dashboards using R Markdown and a convention for how the headers affect the layout:

  • Each level 1 header (#) begins a new page in the dashboard.
  • Each level 2 header (##) begins a new column.
  • Each level 3 header (###) begins a new row.
Rmarkdown for powerpoint

For example, you can produce this dashboard:

Using this code:

Flexdashboard also provides simple tools for creating sidebars, tabsets, value boxes, and gauges. To learn more about flexdashboard visit http://rmarkdown.rstudio.com/flexdashboard/.

29.7 Interactivity

Any HTML format (document, notebook, presentation, or dashboard) can contain interactive components.

29.7.1 htmlwidgets

HTML is an interactive format, and you can take advantage of that interactivity with htmlwidgets, R functions that produce interactive HTML visualisations. For example, take the leaflet map below. If you’re viewing this page on the web, you can drag the map around, zoom in and out, etc. You obviously can’t do that in a book, so rmarkdown automatically inserts a static screenshot for you.

The great thing about htmlwidgets is that you don’t need to know anything about HTML or JavaScript to use them. All the details are wrapped inside the package, so you don’t need to worry about it.

There are many packages that provide htmlwidgets, including:

  • dygraphs, http://rstudio.github.io/dygraphs/, for interactive timeseries visualisations.

  • DT, http://rstudio.github.io/DT/, for interactive tables.

  • threejs, https://github.com/bwlewis/rthreejs for interactive 3d plots.

  • DiagrammeR, http://rich-iannone.github.io/DiagrammeR/ for diagrams(like flow charts and simple node-link diagrams).

To learn more about htmlwidgets and see a more complete list of packages that provide them visit http://www.htmlwidgets.org/.

29.7.2 Shiny

Rmarkdown Powerpoint Presentation

htmlwidgets provide client-side interactivity — all the interactivity happens in the browser, independently of R. On one hand, that’s great because you can distribute the HTML file without any connection to R. However, that fundamentally limits what you can do to things that have been implemented in HTML and JavaScript. An alternative approach is to use shiny, a package that allows you to create interactivity using R code, not JavaScript.

To call Shiny code from an R Markdown document, add runtime: shiny to the header:

Rmarkdown Powerpoint Tables

Then you can use the “input” functions to add interactive components to the document:

You can then refer to the values with input$name and input$age, and the code that uses them will be automatically re-run whenever they change.

I can’t show you a live shiny app here because shiny interactions occur on the server-side. This means that you can write interactive apps without knowing JavaScript, but you need a server to run them on. This introduces a logistical issue: Shiny apps need a Shiny server to be run online. When you run shiny apps on your own computer, shiny automatically sets up a shiny server for you, but you need a public facing shiny server if you want to publish this sort of interactivity online. That’s the fundamental trade-off of shiny: you can do anything in a shiny document that you can do in R, but it requires someone to be running R.

Learn more about Shiny at http://shiny.rstudio.com/.

29.8 Websites

With a little additional infrastructure you can use R Markdown to generate a complete website:

  • Put your .Rmd files in a single directory. index.Rmd will becomethe home page.

  • Add a YAML file named _site.yml provides the navigation for the site.For example:

Execute rmarkdown::render_site() to build _site, a directory of files ready to deploy as a standalone static website, or if you use an RStudio Project for your website directory. RStudio will add a Build tab to the IDE that you can use to build and preview your site.

Read more at http://rmarkdown.rstudio.com/rmarkdown_websites.html.

29.9 Other formats

Other packages provide even more output formats:

  • The bookdown package, https://github.com/rstudio/bookdown,makes it easy to write books, like this one. To learn more, readAuthoring Books with R Markdown,by Yihui Xie, which is, of course, written in bookdown. Visithttp://www.bookdown.org to see other bookdown books written by thewider R community.

  • The prettydoc package, https://github.com/yixuan/prettydoc/,provides lightweight document formats with a range of attractivethemes.

  • The rticles package, https://github.com/rstudio/rticles, compiles aselection of formats tailored for specific scientific journals.

See http://rmarkdown.rstudio.com/formats.html for a list of even more formats. You can also create your own by following the instructions at http://rmarkdown.rstudio.com/developer_custom_formats.html.

29.10 Learning more

To learn more about effective communication in these different formats I recommend the following resources:

R Markdown Powerpoint

  • To improve your presentation skills, I recommendPresentation Patterns, by Neal Ford,Matthew McCollough, and Nathaniel Schutta. It provides a set of effectivepatterns (both low- and high-level) that you can apply to improve yourpresentations.

  • If you give academic talks, I recommend reading the Leek group guideto giving talks.

  • I haven’t taken it myself, but I’ve heard good things about MattMcGarrity’s online course on public speaking:https://www.coursera.org/learn/public-speaking.

  • If you are creating a lot of dashboards, make sure to read Stephen Few’sInformation Dashboard Design: The Effective Visual Communicationof Data. It will help you create dashboardsthat are truly useful, not just pretty to look at.

  • Effectively communicating your ideas often benefits from someknowledge of graphic design. The Non-Designer’s DesignBook is a great place to start.

Word

The package facilitates the formatting of Microsoft Word documents produced by R Markdown documents by providing a range of features:

Rmarkdown Powerpoint Theme

  • Compatibility with the functions of the package officer for the production of “runs” and “blocks” of content (text formatting, landscape mode, tables of contents, etc.).

    You can add a column break in a two-column section, you can easily color a chunk of text, you can add tables of contents at any place in the document and also add a list of figures or list of tables.

  • Ability to use the table styles and list styles defined in the “reference_docx” which serves as a template for the pandoc document.

    With rmarkdown, you can reuse all paragraph styles. With officedown, you can also reuse table and list styles. These features are based on the use of Word templates (reference_docx). It is recommended to learn how “Word styles” work for paragraphs, tables and lists if you never really used Word styles.

    These styles are to be defined in a Word document that serves as a template. You must first create a Word document (or edit an existing Word document), adjust the styles and save it. This document which serves as a vehicle for the defined styles will be used by R Markdown, the argument reference_docx must be filled in with the file path.

  • The replacement of captions (tables, figures and standard identifiers) by captions containing a Word bookmark that can be used for cross-referencing. Also the replacement of cross-references by cross-references using fields calculated by Word. The syntax conforms to the bookdown cross-reference definition.

    The package transforms some specific knitr codes into references calculated by Word, it applies to:

    • cross-references with bookdown syntax
    • table and image captions
    • title identifiers

    It is then easy to copy and paste the content into another document without losing the reference numbers. Captions are also auto-numbered by Word.

  • Full support for flextable output, including with outputs containing images and links.

    The package enable knitting flextable outputs with images or plots in cells without using officer. Insertion of images in flextable is not supported with rmarkdown::word_document but is possible by using officedown::rdocx_document.