problems using square brackets within \Sexpr in Sweave files

I have run into a problem when trying to use \Sexpr{} in Sweave files in RStudio Version 2023.12.0+369 (2023.12.0+369).

The problem is best demonstrated in the image below. I have noticed that when I use square brackets within an \Sexpr{} tag then all of the text (not code) after that tag is interpreted by RStudio as code, and not text. This seems like a bug in the IDE to me. And I will note that this was not happening to me a few months ago. So it seems that in an update of RStudio or maybe knitr something appears to have changed.

If this is happening only in the IDE source mode, this would need to be reported in GitHub - rstudio/rstudio: RStudio is an integrated development environment (IDE) for R if not there already.

If rendering / knitting works ok, usually rmarkdown or knitr is working. Try outside of the IDE to check if it is involved.

Thanks !

Yeah, it does work outside the IDE, so it seems to be an issue with the source mode in the IDE. I will file an issue.

1 Like