简体   繁体   中英

How can I set graphical parameters (par()) and structure options (strOptions()) in a knitr document?

I am working on a knitr-sweave document and have found that global R options like

par(lwd=3)

and

strOptions(strict.width='cut')

do not take effect in later code chunks. I can specify these options as arguments each time I plot() or str(), so it's not a huge problem. I'm just wondering if anyone has any insight into this. Should I be caching the code chunk where I set these options? I call some libraries in early code chunks and set variables in others and they all seem to be accessible "globally" (ie in later code chunks).

I believe I can help you with setting strOptions globally. Just set your str options as a list under options , like this:

options(str = list(strict.width = "cut"))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM