Reputation: 23
I'm trouble getting Rmarkdown to text wrap when it reaches a certain line length. Currently, it adds a horizontal scrollbar, but ideally it would just wrap the text.
I have tried using
knitr::opts_chunk$set(tidy=TRUE,
tidy.opts=list(width.cutoff=60))
It works on some code chunks but not others.
My first code chunk, it works. (code is on the left, output is on the right)
But later in the document, knitr no longer wraps comments. (code is on the left, output is on the right)
How can I force knitr to wrap all the code chunks, including the comments?
Upvotes: 2
Views: 1429
Reputation: 30174
That's because an inline comment (after a line of code) can't be wrapped, otherwise the code will be invalid. For example, you can't wrap
1 + 1 # this is a comment
as
1 + 1 # this is
a comment
If you want comments to be wrapped, you have to write whole lines of comments.
Upvotes: 1