-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YAML chunk options inconsistent use of : and = #863
Comments
This is expected as you are mixing syntax in the example above. Let me explain. About the different formatChunk option in Quarto can be set using YAML syntax, prepending
This syntax can be use with any computation engine, include the OJS, Julia and Jupyter supported by Quarto. When using R, this is equivalent to using option in chunk header using valid R syntax
In fact, knitr supports the syntax natively in R Markdown document too. There is also support for using multiline chunk options using R syntax
This is specific to knitr computation engine, and can also be used within Quarto. All this format supported in knitr have been announced in this blog post https://yihui.org/en/2022/01/knitr-news/ Why different format ?The YAML syntax is mainly here because it allows Quarto to use the same syntax for any computation engine, and not just R. The other syntax are native with R - so you can use any valid R code as chunk option. The multiline version is here by convenience so that you can split in several lines long chunk options. Example from blog post linked above: ```{r}
#| rmdworkflow,
#| echo = FALSE,
#| fig.cap = "A diagram illustrating how an R Markdown document
#| is converted to the final output document.",
#| out.width = "100%"
knitr::include_graphics("images/workflow.png", dpi = NA)
``` The advantage is that you can use R variable without any special character. It will work in Quarto but this is specific to knitr and won't obviously work with Python or else. About your exampleIn your example, you are using That is why you see an error in the first case - it needs to be valide YAML or using ```{r}
#| label: demo2
#| echo: 3
month <- "July"
str(month)
```
```{r}
#| label: demo4
#| echo: !expr c(3)
month <- "July"
str(month)
```
I hope this clarify how this works. Full example---
title: "My simple title"
author: "My name and ID"
format: html
---
# Using header option
```{r, label = "demo", echo = c(3)}
month <- "July"
str(month)
```
# Using multiline syntax
```{r}
#| label = "demo1", eval = TRUE,
#| echo = c(3)
month <- "July"
str(month)
```
# Using YAML syntax
```{r}
#| label: demo2
#| echo: 3
month <- "July"
str(month)
```
# Using yaml with R code to parse
```{r}
#| label: demo4
#| echo: !expr c(3)
month <- "July"
str(month)
``` |
Many thanks both, apologies, I'm new to quarto! |
No need to be sorry. It means things as not as clear as they should. It can be confusing to support multi syntax but with Quarto we are only advertising one (the YAML syntax) as this is the one that is portable across engine. You should use that one first for new document. For old Rmd document, no need to convert - the usual syntax is working fine with Quarto too. |
A related question: is it possible to hide the output of certain lines of code? For example;
Can I show 'mtcars' in the code chunk after the render but not 'rmarkdown::paged_table(mtcars)' and in addition to that have only the result of the paged_table() shown? |
@jeweljohnsonj It is not directly a Quarto question, and not related to this issue. Please next time ask in the right place.
Best way would be ```{r, eval= FALSE}
mtcars
```
```{r, echo = FALSE}
rmarkdown::paged_table(mtcars)
``` This will work in Quarto I would have try this: ```{r, echo = -2, eval= 2}
mtcars
rmarkdown::paged_table(mtcars)
``` but it will add Hope it helps. @plukethep I am closing this, I think we're good. |
Hi, please see this:
The following YAML bring up an error
The text was updated successfully, but these errors were encountered: