Home > OS >  Evaluate code block in quarto dependant on evaluation of an R variable
Evaluate code block in quarto dependant on evaluation of an R variable

Time:01-12

I have the following quarto document, and I want to execute the second code block depending on the value of OK. As below, it does not work. I tried double and triple backticks, using only OK, but nothing worked. How can I do this?

---
title: "Test"
format: html
---

## Set a variable

```{r}
OK <- FALSE
```

## Running Code depending on value of `OK`

```{r}
#| eval: `r OK`
print("OK is TRUE - otherwise you won't see anything here.")
```

CodePudding user response:

You can use R code as chunk option values by prefacing them with use of r code as chunk option


  • Related