Installation
You can install the current version of renderthis from GitHub:
# install.packages("remotes")
remotes::install_github("jhelvy/renderthis")
Some output formats require additional packages, and each format will provide instructions about how to install any missing dependencies. You can also choose to install renderthis with all of its dependencies:
# install.packages("remotes")
remotes::install_github("jhelvy/renderthis", dependencies = TRUE)
Note: To get the most out of renderthis, we recommend installing the package with dependencies and making sure that you have a local installation of Google Chrome.
Usage
Use renderthis to render media to different formats. Here is a diagram of the render hierarchy:
To use renderthis, first load the package:
library(renderthis)
All of the package functions follow a common pattern:
- All functions use
to_*()
to render media to a desired format (e.g.,to_pdf()
). - All functions use thefrom
andto
arguments:- The
from
argument is required and can be a full or local path to the input file. - The
to
argument is optional. If provided, it can be a full or local path to the output file, and it must end in an appropriate extension (e.g.slides.gif
forto_gif()
). If it is not provided, the output file name will be determined based on thefrom
argument.
- The
You can render all of the examples below from here
Render PDF
Input can be a Rmd / qmd file, html file, or url:
to_pdf(from = "slides.Rmd")
to_pdf(from = "slides.html")
to_pdf(from = "https://jhelvy.github.io/renderthis/reference/figures/slides.html")
Note: Rendering the PDF requires a local installation of Google Chrome
Render GIF
Input can be a Rmd / qmd file, html file, pdf file, or url:
to_gif(from = "slides.Rmd")
to_gif(from = "slides.html")
to_gif(from = "slides.pdf")
to_gif(from = "https://jhelvy.github.io/renderthis/reference/figures/slides.html")
Example:
Render PPTX
Creates a pptx file where each slide contains a png image of each slide. While you won’t be able to edit the content from Powerpoint, you can at least annotate it.
(See the slidex package by @datalorax to do the opposite: pptx –> xaringan!)
Input can be a Rmd / qmd file, html file, pdf file, or url:
Render PNG
Render png image(s) of some or all slides. Use the slides
argument to determine which slides to include (defaults to 1
, returning just the first slide).
Input can be a Rmd / qmd file, html file, pdf file, or url:
# By default, a png of only the first slide is built
to_png(from = "slides.Rmd", to = "title_slide.png")
to_png(from = "slides.html", to = "title_slide.png")
to_png(from = "slides.pdf", to = "title_slide.png")
to_png(from =
"https://jhelvy.github.io/renderthis/reference/figures/slides.html",
to = "title_slide.png"
)
# Use the `slides` argument to control which slides get rendered into pngs
to_png(from = "slides.pdf", to = "first_slide.png", slides = "first")
to_png(from = "slides.pdf", to = "last_slide.png", slides = "last")
to_png(from = "slides.pdf", slides = c(1, 3, 5)) # Choose subsets of slides
to_png(from = "slides.pdf", slides = -1) # Negative indices remove slides
to_png(from = "slides.pdf", slides = "all")
Example:
“Complex” slides and partial / incremental slides
“Complex” slides are slides that contain panelsets or other html widgets / advanced features that might not render well as a pdf. To render these on each slide, set complex_slides = TRUE
.
If you want to render a new slide for each increment on incremental slides, set partial_slides = TRUE
.
These options are available as options in any of the functions that depend on rendering the pdf:
Note: These options require the chromote and pdftools packages.
Author, Version, and License Information
- Authors: John Paul Helveston (aut, cre, cph) & Garrick Aden-Buie (aut)
- Date First Written: Originally as {xaringanBuilder} on September 27, 2020
- License: MIT
Citation Information
If you use this package in a publication, I would greatly appreciate it if you cited it. You can get the citation information by typing citation("renderthis")
into R:
To cite renderthis in publications use:
Helveston, John Paul and Aden-Buie, Garrick (2021). renderthis: Render media to different formats.
A BibTeX entry for LaTeX users is
@Manual{, title = {renderthis: Render media to different formats.}, author = {{Helveston} and John Paul and {Aden-Buie} and {Garrick}}, year = {2021}, note = {R package version 0.0.1}, url = {https://jhelvy.github.io/renderthis/}, }