class: center, middle, inverse, title-slide # {renderthis} ## Render media to different formats ### John Paul Helveston & Garrick Aden-Buie ### 2022-04-14 --- background-image: url(https://upload.wikimedia.org/wikipedia/commons/b/be/Sharingan_triple.svg) ??? Image credit: [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:Sharingan_triple.svg) --- ## Installation You can install the current version of renderthis from GitHub: ``` # install.packages("remotes") remotes::install_github("jhelvy/renderthis") ``` -- .pull-left[ #### Supported output types: - html - pdf - gif - mp4 - pptx - png - social: png image of first slide sized for social media sharing (e.g. Twitter) ] -- .pull-right[ #### Render hierarchy: ``` Rmd / qmd | |--> social (png) | |--> html | |--> pdf | |--> png | |--> gif | |--> mp4 | |--> pptx ``` ] --- ## Partial / incremental slides For `pdf`, `png`, `gif`, `mp4`, and `pptx` output types, if you want to render a new slide for each increment on [incremental slides](https://slides.yihui.org/xaringan/incremental.html#1), set `partial_slides = TRUE` in any of the following render functions: ``` to_pdf() to_png() to_gif() to_mp4() to_pptx() ``` -- For example, the following code would render this slide as two slides in a pdf instead of one: ``` to_pdf("slides.Rmd", partial_slides = TRUE) to_pdf("slides.html", partial_slides = TRUE) ``` > **Note**: This option requires the [chromote](https://github.com/rstudio/chromote) and [pdftools](https://github.com/ropensci/pdftools) packages. --- ## Complex slides "Complex" slides are slides that contain [panelsets](https://pkg.garrickadenbuie.com/xaringanExtra/#/panelset) (like the one on this slide) or other html widgets / advanced features that might not render well as a pdf. To render these on separate slides, set `complex_slides = TRUE` in `to_pdf()`, `to_png()`, `to_gif()`, `to_mp4()`, or `to_pptx()`. .panelset[ .panel[.panel-name[Chunk] ```r head(mtcars) ``` ] .panel[.panel-name[Output] ``` ## mpg cyl disp hp drat wt qsec vs am gear carb ## Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4 ## Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4 ## Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1 ## Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1 ## Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2 ## Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1 ``` ] ] --- ## Use the `slides` argument to control which slides get built Examples rendering from PDF to PNG: ```r # Render the first or last slide only to_png(from = "slides.pdf", to = "first_slide.png", slides = "first") to_png(from = "slides.pdf", to = "last_slide.png", slides = "last") # Choose subsets of slides to_png(from = "slides.pdf", slides = c(1, 3, 5)) to_png(from = "slides.pdf", slides = -1) # Negative indices remove slides # Render all slides to_png(from = "slides.pdf", slides = "all") ``` --- class: center, middle, inverse # Thanks! Slides created via the R package [**xaringan**](https://github.com/yihui/xaringan). Package documentation at https://jhelvy.github.io/renderthis <a href='https://xaringan.club/'><img src='https://github.com/dynastyprocess/graphics/raw/main/xaringanclub/xaringanclub.png' align="center" height="142" /></a> Visit [xaringan.club](https://xaringan.club/) for more {xaringan} tools!