Closed ralmond closed 10 months ago
For the context, this is following report at https://github.com/quarto-dev/quarto/issues/211
As commented there, the warnings are thrown when running chunks interactively in RStudio IDE.
One of the warning is from RStudio code path for sure: https://github.com/rstudio/rstudio/blob/a9a0652e3feac02a05caeead5d54e370f3ec4209/src/cpp/session/modules/SessionRmdNotebook.R#L686
So I believe this is an RStudio IDE issue.
About what is happening, this is related to
#| tbl-subcap:
#| - "Var3 = 1"
#| - "Var3 = 2"
If the =
are removed, there is no more warning.
And when run under Quarto does not properly format the chunk (or register the label as a cross-reference).
I answer on quarto side. Document is running fine, but crossref feature does not work because the output is not a table. You can't use the table features if the output of the chunk is not a table.
Issue has been opened upstream: https://github.com/rstudio/rstudio/issues/13326
I left out the calls to kable
in the example, as they weren't needed to generate the warning, but they were in the source document. I was still getting the cross-reference problem there, as the label was not getting properly set (see warning) So I think that is probably a secondary effect of the caption parsing problem.
I was still getting the cross-reference problem there, as the label was not getting properly set (see warning) So I think that is probably a secondary effect of the caption parsing problem.
Please to try the example I shared in the Quarto thread
---
title: Table
format: html
---
```{r}
#| label: tbl-tab
#| echo: false
#| tbl-cap: "A 3-way array"
#| tbl-subcap:
#| - "Var3 = 1"
#| - "Var3 = 2"
arr <- array(1:24,c(4,3,2))
knitr::kable(arr[,,1])
knitr::kable(arr[,,2])
Look at Table @tbl-tab, just look at it.
This renders correctly with Quarto
![image](https://github.com/yihui/knitr/assets/6791940/3b113698-6fc5-4687-a966-ba0fb66c3b58)
No warning, and no complain about not being able to find cross-reference `@tbl-tab`.
So please, do check you Quarto version, and check that the label use in the chunk is the same as the one in the reference, and also that you code chunk correctly outputs table.
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.
Including the characters
=
,,
, and probably others inside of a caption causes difficulties, and knitr doesn't ignore any special meanings of quoted characters.Minimal example:
Warning messages: 1: In value[3L] : Failed to parse chunk options in body: Error in parse(text = code, keep.source = FALSE)::1:24: unexpected symbol
1: alist( label: tbl-tab1 tbl
^
2: In opts$engine <- unlist(strsplit(rmdChunkOpts, split = "(\s|,)+"))[[1]] : Coercing LHS to a list
Locale: LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: America/New_York tzcode source: system (glibc)
Package version: evaluate_0.21 graphics_4.3.1 grDevices_4.3.1 highr_0.10 knitr_1.43 methods_4.3.1 stats_4.3.1
tools_4.3.1 utils_4.3.1 xfun_0.39 yaml_2.3.7