How to Make RStudio Presentation Self-contained? - r

I'm writing a presentation in R using RStudio. To create new presentation, I select "R Presentation" from the File => New File menu. RStudio creates new document. Here is the template:
New Presentation
========================================================
author:
date:
First Slide
========================================================
For more details on authoring R presentations click the
**Help** button on the toolbar.
- Bullet 1
- Bullet 2
- Bullet 3
Slide With Code
========================================================
```{r}
summary(cars)
```
Slide With Plot
========================================================
```{r, echo=FALSE}
plot(cars)
```
Once a presentation is created, it can be saved as an HTML. However, I cannot find an option to make it a self-contained HTML file.
As a counter-example, I can create a self-contained HTML file using Rmarkdown:
---
title: "Habits"
output:
ioslides_presentation:
mathjax: local
self_contained: false
---
Source: http://rmarkdown.rstudio.com/ioslides_presentation_format.html
What is the equivalent of this code in RStudio R Presentation?
Additionally, does anyone know why they did it both ways?
SOLVED (09/25/2017)! See Nova's answer below. Here is a screenshot to show how I did it:

I've been able to "export" the presentation to html by going to the "Presentation" tab in RStudio, clicking the gear shift icon where it says "More", and choosing "Save as Webpage". This saved a stand-alone .html file that works when I open it from a different folder location.

Related

Create a slidy presentation from *Quarto*

Create a slidy presentation using R markdown is straightforward R Markdown: The Definitive Guide. By
Yihui Xie, J. J. Allaire and Garrett Grolemund.
I try Quarto document (HTML format) to create such presentation (Multiple html page in one file), but horizontal rule (---) do not work to create a new slide/page.
Is there any way to create such presentation using Quarto?
Thanks
---
title: "Test document"
format: html
---
## Running Code
When you click the **Render** button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
```{r}
1 + 1
```
---
You can add options to executable code like this
```{r}
#| echo: false
2 * 2
```

Include logo (image) on every page of R markdown pdf

I am trying to include my company logo in an R markdown report. The output has to be pdf. The logo has to be used as a template on every page of the report in the top left of the file. Just for example, you can use this google logo https://en.wikipedia.org/wiki/Google#/media/File:Google_2015_logo.svg
I want the report to look like this (sorry for the blurry image but I just wanted to give an example) -
The google logo on top left should be present on every page.
I have done searches but all the searches that I have done are showing how to do this using latex or HTML output.
https://bookdown.org/yihui/rmarkdown-cookbook/latex-logo.html
Insert a logo in upper right corner of R markdown pdf document
2 Logo in R Markdown on PDF
add image in title page of rmarkdown pdf
The closest I have came is with this markdown document that is called reports.Rmd which looks like -
---
title: "Report"
output: pdf_document
params:
study: NA
mid : NA
---
![Caption.](google.png)
```{r, echo=FALSE}
paste0("Study : ", params$study)
paste0("ID", params$mid)
```
and I run this from another R script as -
library(rmarkdown)
study <- 'ABC'
mid <- '73023'
rmarkdown::render('reports.Rmd', pdf_document(), params = list(
study = study, mid = mid
))
This runs and produce this output
I'll be able to resize the image with How to set size for local image using knitr for markdown? but I don't know how to place this on top left of the page. Thank you for reading.
This is a template for you:
---
title: 'You are really need to use LaTeX'
author: "You"
date: "`r Sys.Date()`"
output:
pdf_document
header-includes:
\usepackage{fancyhdr}
\usepackage{graphicx}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
\addtolength{\headheight}{3.0cm}
\fancypagestyle{plain}{}
\pagestyle{fancy}
\fancyhead[R]{\includegraphics[width = 100pt]{your_pic.png}}
\renewcommand{\headrulewidth}{0pt}
This is an R Markdown document. Markdown is a simple formatting syntax for
authoring HTML, PDF, and MS Word documents. For more details on using R Markdown
see <http://rmarkdown.rstudio.com>.
and blah-blah...
So, don't forget to install LaTeX and packages fancyhdr, graphics.
How to do it, you can see there.
Or you can install MikTeX etc. You can find a lot of info at the SO/in the web.
The knowledge of LaTeX will save you not once a time in the future life ;)

R Markdown: Creating Backgrounds for Powerpoints

I'm using R markdown to create a presentation, and I would really like to add a custom background on my opening slide and second slide. Currently, I have my potential themes on a separate PowerPoint document. Is there any way to add backgrounds like that?
Thanks!
To add a custom background, one can create a powerpoint template, e.g. my-styles.pptx where the background image is placed at the slide master.
Then create an Rmarkdown file like follows and place it in the same folder:
---
title: "Fancy Slides"
author: "Creative Author"
date: "2021-06-09"
output:
powerpoint_presentation:
reference_doc: my-styles.pptx
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
## Slide with R Output
```{r cars, echo = TRUE}
summary(cars)
```
More about this can be found in Yihui Xie et al. (2021) R Markdown: The Definitive Guide, Section 4.4.
Tested with RStudio Version 1.4.1714 and Powerpoint 2016.

rmarkdown beamer presentation: how to not print section slides?

I am writing a beamer presentation in rmarkdown and converting it to pdf with knitr. I want to define sections at the header1 level, e.g. # Introduction, and then have a slide titled something else e.g. ## Introducing my brilliant research. Having the header1 level define sections is nice as the names of the sections can be displayed in the slide header in certain beamer themes, and this is why I include it.
But I do not want rmarkdown to insert a slide that simply says the name of the section between sections, which at the moment it is doing. Is there a way to not print a slide with the section name between sections? I thought slide_level would control this behavior but it does not seem to (or perhaps I am using it wrong).
A minimal reproducible example of my problem can be obtained with this code:
---
title: "Test Pres"
author: "Professor Genius Researcher"
date: "24 February 2017"
output:
beamer_presentation:
slide_level: 2
theme: "Singapore"
colortheme: "rose"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
# Markdown Intro
## R Markdown
This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.
# Using Bullets
## Slide with Bullets
- Bullet 1
- Bullet 2
- Bullet 3
# Including Chunks
## Slide with R Output
```{r cars, echo = TRUE}
summary(cars)
```
## Slide with Plot
```{r pressure}
plot(pressure)
```
At the moment, this code produces slides that say Markdown Intro, Using Bullets, and Including Chunks. I would like those slides labeling the sections omitted. Is this possible?
Create a new Latex template where you remove this part from the preamble:
\AtBeginSection[]
{
....
}
Place this latex template in the same folder as your .Rmd file and refer to it in the Rmd Yaml front matter using template: mytemplate.tex as explained here.

How to export R shiny presentation to pdf or html

I built an interactive shiny presentation in Rstudio. Header of the .Rmd file is:
---
title: "title"
author: "author"
date: "date"
output:
ioslides_presentation:
mathjax: "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
runtime: shiny
---
I generate really nice slides with interactive elements. No problem. However, I cannot knit the document as html or pdf files. I think this's by design since I specifically select "runtime: shiny". Is there an alternative way to capture the presentation as pdf/html file even if it means loss of the interactive elements? The only solution I could come up with is capture a screenshot for every slide from the browser and save it separately. But this's laborious...
You can Knit on-demand screenshots of the app by following these instructions.

Resources