28.7 SweaveOpts Undefined

20200602 Be sure to select knitr under Tools \(\rightarrow\) Global Options \(\rightarrow\) Sweave \(\rightarrow\) Weave Rnw files using:. If you have initially run your document using Sweave rather than knitr (Xie 2023) (RStudio defaults to Sweave) and then attempt to change to knitr (Xie 2023), you may find the following Undefined control sequence error:

! Undefined control sequence.
l.54 \SweaveOpts
                {concordance=TRUE}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

We will find this error message towards the end of the log file obtained by clicking the View Log button. A popup will also tell us that we can convert the file using Sweave2knitr("report.Rnw")

RStudio has automatically inserted a required line for compiling with Sweave. As the error message suggests, go to the line containing the undefined sequence (line 54 is noted in this instance, but that is in the automatically generated .tex file rather than the source .Rnw file that we are editting so we will need to search for the string) and delete the offending LaTeX control sequence and the bracketed argument. It should then run just fine in knitr (Xie 2023).

References

———. 2023. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0