So let's keep using the same GitHub repository and
the same RStudio project for module two RMD one.
Go ahead and open this in your RStudio.
We're going to create new R Markdown files for
different presentation formats in this repository.
And this repository should be saved on
your local hard drive at RepTemplates/Module2_rmd1.
Let's create a new R Markdown file,
but this time instead of creating a document we're going to do a presentation.
We're first going to do the HTML format ioslides.
So let's type in the title for this like Module 2- ioslides and click OK.
This creates a default template for making an ioslides presentation.
Let's take a quick look at the YAML header.
The keywords of title,
author and date are very similar to
the YAML header that you did earlier for your HTML document.
But notice that the output has changed to ioslides_presentation.
This tells R Markdown that this document is going to be
rendered as an ioslides HTML formatted presentation.
This template has some very similar elements and formatting to
the basic R Markdown HTML document that we created earlier.
However this time in ioslide,
the two hashtags for level two headers are actually the titles for each new slide.
The template shown here has four level
two headers indicating that this is going to have four slides.
The first slide, pass some basic text and description of R Markdown.
The second slide, has a list with three bullets.
The third slide, has a summary of the built in car's data set.
The fourth slide, shows a plot of the pressure data set.
Let's go ahead and Knit to HTML to see these final slides.
The first time you do this,
it's going to ask you to save the file name,
so let's save it like something like module2_ioslides, and click save.
When the document completes compiling,
you'll actually notice that there really are five slides.
The first slide shown here is your title slide and this was
actually generated using the information contained in the YAML header.
The other four slides were created using level two headers with the two hashtags.
In your YAML header,
let's try changing a few things,
like your title or the author or the date,
and Knit to HTML and see how the changes show up in your title slide.
So in the ioslides format,
changing the information in your YAML header changes what's shown on your title slide.
We can also open these in a browser.
So go to your file directory,
find the file for Module2_ioslides.html and open this in a browser window.
There are some nice features of the ioslides format,
one of which is the ability to view the slides in
a normal width height ratio or in a wide format.
So while you're looking at these slides in a browser,
you can type the letter W to toggle back and
forth between a wide and a normal ratio format.
You can also view the slides in a full screen mode by typing the letter F,
and if you want to bring the browser window back, just click F again.
Let's also try making these slides in the Slidy HTML format.
We can actually do this in one of two ways,
we can either create a new R Markdown file and choose presentations and this time,
choose the Slidy format or since we already have the ioslides formatted file open,
we can simply Knit to HTML Slidy,
and the output format will automatically be changed in
the YAML header and your Slidy formatted slides will be created.
But before we do this,
let's go ahead and save this file as
another file name to keep him separate from the ioslides format.
So let's say file,
save as and this time instead of module2_ioslides,
it will say module2_slidy, click save.
Now, click Knit to HTML Slidy.
When we do that, the YAML header changes automatically and
our slides are produced in Slidy format instead of
ioslides format and you can see the difference is shown here in the viewer window.
We can page through the slides and you can
get an idea of how the slides look a little bit
different with the Slidy format instead of ioslides format.
So take a few moments now and choose either one of these,
the ioslides or the Slidy and spend some time adding some new slides,
inserting an image, video or equation and view the results.
You can use the text in R Markdown syntax that
we've created earlier for the R Markdown HTML document.
Everything should work as expected in HTML except for the footnotes,
these are not supported in ioslides or Slidy but they do work in the Beamer PDF format.
This shows you that you always have to check the documentation for
each format because some of the options are not supported across all formats.
For example, like the animations or the videos they don't work in PDF or DOC formats.
It's a good idea to read through the documentation for each Markdown format.
If you go to the R Markdown website, shown here,
and click on formats you'll notice
that there are links here for all the different formats.
For example if we click on presentations for ioslides,
there's lots of help here on the options and what's available and what works in ioslides,
you can also click on Slidy and see the similar details shown here.
For now, let's add three slides to our ioslides or
your Slidy presentation based on what we did earlier in the R Markdown HTML document.
For example, we can add a slide with an inserted image,
we'll do this just like we did before where we type in,
here's an image inserted,
there's the sunstar link for that inserted image.
We could insert a table using the knitr::
kable(head(cars) command that you saw
earlier and we could also have a slide with an equation.
For example here is the simple linear regression equation that we
showed previously using the LATEX Commands.
Let's click save and Knit to HTML,
so that you can see these results.
For now I'm going to show you how to do this with ioslides.
So here are the three new slides.
This one with the inserted image,
the table and the equation.
You'll notice that the slide with the sunstar image,
shows the word sunstar below the image.
This is because we included some text for the alt text in the first set of brackets.
To remove this word,
we just need to remove it and leave it blank.
So let's exit out of the viewer and we'll go back to where we had
the sunstar image but this time I'm going to take out the alt text.
The alt text is there basically to make your HTML web pages be more user friendly.
However, when you have that in there with slides it's a little distracting.
Let's Knit to HTML and you can see the result.
Another thing you'll notice about RStudio,
is that when you're making changes like this where you make a change,
the preview window opens at that point.
So here's the image again inserted but this time without the sunstar alt text.
So now that we've done this with the ioslides format,
let's also do it with Slidy.
The syntax is exactly the same,
so we've got a slide here with the inserted image,
a slide with a table and a slide with the equation.
Let's go ahead and we'll remove the alt text here,
and we'll click save and Knit to
HTML and you can see what these look like in the Slidy format.
So if we page through,
you can now see what the slide looks like with an inserted image,
the table and the equation.
Let me show you a couple of other features.
Suppose that we wanted to center the image of the sunstar on that slide,
at the end of the title for that slide,
in curly brackets, we can add these options.
We type in {.flexbox.vcenter} for vertical center.
Now if we click save and Knit to HTML,
our sunstar image should be centered on the slide.
There you go. The image has now been centered.
You can learn more about these options as I pointed out
previously on the R Markdown website for the ioslides format.
Another format that's helpful to use sometimes is adding multiple columns on a slide,
and you can do this using the ioslide options for columns.2.
So let's try doing this now.
We're going to add one more slide down here at the bottom.
And we'll have a slide with two columns.
And at the end of that, we type in.columns-2.
So, we've got a slide here with two columns.
The first thing we're going to show is that Sunstar image,
we embed code, is shown here followed by three bullets.
Let's click save, and knit to HTML so you can see the result in the ioslides format.
Here are your two columns,
the image on the left side and the three bullets are shown on the right.
It's worth noting that this two-column option will not work for the Slidy format,
and it will not work for the Beamer PDF format.
Optionally, if you have LaTeX installed,
we can actually knit to PDF.
This is going to be the Beamer format.
So, let's take this now and save this as module2_beamer.
So, this time, we'll say knit to PDF for the Beamer format.
And you'll get a chance to see what these slides look like using the PDF format.
So, here is the PDF format for the Beamer slide format.
We can page through these and you get a chance to see what these look like.
Again, everything works as expected except for the two columns.
Another HTML presentation format that's gaining popularity is the reveal.js format.
There's some information shown here on the R Markdown website for the reveal.js format.
To use this format,
we're first going to have to install the R package for this slide presentation format.
You can do this on one of two ways.
In RStudio, click on tools and install packages.
Here, You can type in the reveal.js package name,
and it's worth noting that you're downloading this from the CRAN repository.
Alternatively, you can also type in the
install.packages command in the console window input in the reveal.js package name.
to install this package.
Take a few moments and go ahead and make sure that this package is installed.
Once the reveal.js package is installed,
we can access a slide template from this packet.
Click on file, new file, R Markdown.
But this time instead of selecting document or presentation,
we're going to select from template.
Now, that we've got the reveal.js package installed,
one of the templates listed should say reveal.js presentation HTML.
Click on that and then click OK. By the way,
any other R packages that you have installed that have
R Markdown templates are listed here in the templates window.
Later, you're going to learn about additional R packages and the templates available,
and how to create an R package with your own template.
But for now, let's go ahead and create
a new R Markdown file using the reveal.js presentation template.
And click on reveal.js presentation HTML here and click OK.
When we do this, this is going to create a set of slides
similar to those that we just did using ioslides or Slidy.
You'll notice that when the new R Markdown file is created,
the YAML header is slightly different.
The only thing shown here is the title and output.
Let's go ahead and add back your author and date to your YAML header.
So, after the title lets put in author followed by a colon,
and inside double quotes, type in your name.
We'll also add the date here inside double quotation marks,
and we'll put in a title.
So, this is "Module 2 - Reveal JS Presentation."
Let's click save and we'll give it a file name module2_reveal.js, click save.
This time, when we knit,
you'll notice that the only option it gives us is knit
to reveal.js presentation, go ahead click that.
Again, these are HTML formatted slides and they'll open in a viewer window.
And the slides are produced with the default slide transition animation.
What if we wanted to change this?
Let me show you how to do this.
Here are some information from the reveal.js website.
If we click on the link shown here for slide transitions,
you'll notice that it shows you how to edit your YAML header.
We're going to do this, and we're going to change the transition
from the example shown here, fade to zoom.
So, change your YAML header now.
To do this, we need to move the reveal.js link down one line and add two spaces.
We need to add a colon on the end,
and then we add the key word for transition followed by a colon,
and the option we want which is zoom.
Let's click save and knit to HTML to see the changes.
When the viewer window opens this time and you page through the slides,
you should notice that the slide transition has changed.
The reveal.js format also utilizes themes to apply styling to the slides using color.
Let's look at the example shown here on the reveal.js website.
If you click on the link for appearance and style,
you'll notice that you can also control things like theme,
highlighting, centering, and so forth.
For now, let's add a couple of these to yours just to see the changes.
So, we've already, for the output,
we've changed the transition.
Let's also change the theme.
So, we're going to add a new line for theme,
and let's pick a theme called Solarized.
We could even change the highlighting for the R code that gets shown,
and will pick something like Kate.
Click save and knit to HTML so you can see the results.
Now, when the slides load,
you'll notice that the background colors have changed along with the fonts.
We could also, if we wanted,
add the option for center and we would set that to true,
and you could knit this again and see the changes that occur.
This time, the information contained on the slides will be centered.
All of the keywords after the reveal.js presentation are
specific parameters or options that are available in the reveal.js presentation format.
So, take a few moments and try some different options in settings,
modifying your YAML header.
Refer back to the reveal.js website here,
and pick some of these different themes and highlights and test them out.
Finally, let's make sure we back everything up,
and save your changes to your GitHub repository.
So again, open Git BASH and type in the different commands to back everything up.
If we typing git status,
we can see all of the new slides,
formats that we've created.
We're going to add these and stage them.
Next, we're going to commit,
so we've added two slide formats,
and we're going to push things to sync them with our GitHub account,
type git status one more time just to double check,
and then go to your GitHub account and click refresh,
and you should now see all of the new slide formats backed up in your cloud account.