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" (i.e. in later code chunks).
par
is only supposed to affect the current graphical device. I am a bit surprised thatstrOptions
doesn't have a durable effect. – IRTFMop <- par(pch = '$', col = green)
work in a subsequent chunks by callingop
again? – rawrpar()
, it is because knitr opens a new device for each code chunk. Perhaps I should recordpar()
throughout the session to make the settings persistent. Personally I often use a chunk hook to set par(), e.g. github.com/yihui/knitr/blob/… – Yihui Xie