10.8 Create slideshows with RMarkdown - Video Tutorials & Practice Problems
Video duration:
3m
Play a video:
Video transcript
<v Voiceover>It is now easier than ever</v> to generate beautiful looking slideshows all within R. Again, this uses the R Markdown package to convert Markdown code to HTML5 slideshows. Some examples are available at my website at jaredlander.com/talks. My most recent talk was Confidence in the Lasso about lasso regression and this whole slideshow was generated using Markdown and Rstudio. We'll come up to the new file button and click R Markdown. Now of course, everything we're doing in R Studio by clicking buttons can be done from the R console, purely by typing in code. Just that R Studio makes it a little more convienent for some of these tasks. We'll go ahead and select presentation then we will call it A Simple Presentation. It does give the option of creating a beamer slideshow which uses LaTeX to generate a PDF slideshow but these days HTML slideshows just seem so much better. So we will go with that option. We click okay and it generates a simple file for us. Again, we see the yaml header which gives the title, the author, the date and the output type which in this case is ioslides_presentation. Slides are demarcated by two hashes You want to create a new slide, you put two hashes and then give it a title. You can see, you can put bullets in here, you could put R code. Let's run this and see what happens. We now have a slideshow that we can navigate using the arrow keys. Here's a slide with R Code and here's a slide that outputted a graph. We can come into the options and we could change if we want it to be io slides or Beamer. We're going to stick with io slides. You could put in a logo, you can change the syntax highlighting, the slide transition speed. You can come to figures and put a caption in them, you can scale them for retina displays, you can change the default size, you can come to advanced and tell it to use widescreen dimensions. You could do all sorts of stuff. And this is what I really like, create standalone HTML presentation. If your presentation has a lot of images, those images are embedded right into the slideshow. If you want to give this HTML file to someone else, you don't need to give them the file and images, you just give them the file and images are embedded. We'll click okay, we didn't make any changes to the settings so our yaml header doesn't change. With just this simple bit of code and using a few hash symbols it is very easy to generate HTML5 slideshows that can be beautifully rendered in a modern browser.