Skip to content

Conditional Slide Rendering in Quarto Presentations Based on Dataframe Size (RStudio) #13213

Answered by mcanouil
nerazhu asked this question in Q&A
Discussion options

You must be logged in to vote

In order to do that, you need to generate the whole slide markdown in your code.

Note that you should have nothing except the language between the brackets. If you want to add a label, use #| label: setup.

---
title: "Example Presentation"
format: pptx
---

```{r}
#| label: setup
#| output: asis
# example dataframe
df_companyX <- data.frame(
  x = 1:5,
  y = rnorm(5)
)
if (nrow(df_companyX) >= 5L) {
  cat("## Slide that validates condtion")
}
```

Could you properly format your post using code blocks for code and terminal outputs? Thanks.
If your code contains code blocks, you need to enclose it using more backticks, i.e., usually four ````.
See https://quarto.org/bug-reports.html#formatt…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nerazhu
Comment options

Answer selected by nerazhu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants