rmarkdown text and plot

Hi,

In the code below I am looking to show text on a slide then below that show a plot. I am trying to do that in a one-column format on the "Slide with Plot" and in a two-column format on the "Two Column Slide". Can you advise how that is possible?

Below the text appears but the plots do not appear using plot() or print(plot()).

Thank you

---
params:
  set_title: "My Title"
title: "Test"
subtitle: "Test"
output: 
  powerpoint_presentation:
    reference_doc: template.pptx
---


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE  , comment = NA, message= FALSE, warning = TRUE)
```


2## 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.

## Slide with Bullets

- Bullet 1
- Bullet 2
- Bullet 3



## Slide with R Output

```{r cars, echo = TRUE}
summary(cars)

```



## Slide with Plot

some text  

```{r pressure, echo= FALSE, comment = FALSE, message= FALSE, warning = FALSE, results='asis'}

cat("\n\n more text")
plot(pressure)
cat("\n\n")

```

## Two Column Slide

:::::::::::::: {.columns}
::: {.column}

1st column test
```{r pressure2, echo= FALSE, comment = FALSE, message= FALSE, warning = FALSE, results='asis'}

cat("\n\n More 1st column text \n\n")
plot(pressure)  
cat("\n\n")

```
:::
::: {.column}

2nd column text

```{r pressure80}

print(plot(pressure))
```
:::
::::::::::::::

You can't really use results = 'asis' with plot inside the chunk. The plot won't be process as it should by knitr.
Results asis is for including a cat() output asis in the markdown document. Plot won't return something you can include like this.

I think you need a recent version of Pandoc for this to work. You may need to use RStudio IDE daily version or install a recent pandoc yourself.

This is because you need to have the Comparison layout available (Pandoc - Pandoc User’s Guide)

Then you should be able to use text and plot in the same column

## Two Column Slide

:::::::::::::: {.columns}
::: {.column}

1st column test

```{r pressure2, echo= FALSE, comment = FALSE, message= FALSE, warning = FALSE}
plot(pressure)  
```
:::
::: {.column}

2nd column text

```{r pressure80}
print(plot(pressure))
```
:::
::::::::::::::

Thank you. I have pandoc version 2.7.2 and rmarkdown 2.1 and running your code above does not show the plots. Do you know versions are necessary for the comparison layout?

At least Pandoc 2.15 I believe

I have 2.7.2 so I think it should work but no luck. I am using reference_doc: template.pptx and I added a layout slide in that pptx file called "Comparison" with the comparison layout but I still do not see the plot. Also, to tesst, I removed the reference_doc: template.pptx and no plots appeared.

The template.pptx file now has 5 layouts. The 4 listed here: https://support.rstudio.com/hc/en-us/articles/360004672913-Rendering-PowerPoint-Presentations-with-the-RStudio-IDE plus the comparison layout.

Any thought on why it doesn't work with 2.7.2?

Because it requires Pandoc 2.15 at least, which is newer than 2.7.2. You have a version which is too old as I said above.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.