Closed schloerke closed 3 years ago
How would you solve this (appart from manually copying and rearranging the output)?
TIL...
You can set an option (probably in a hidden chunk) to limit the width:
str(letters)
#> chr [1:26] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" ...
options(width = 40)
str(letters)
#> chr [1:26] "a" "b" "c" "d" "e" "f" ...
Created on 2021-07-15 by the reprex package (v2.0.0)
According to https://bookdown.org/yihui/rmarkdown-cookbook/text-width.html, this does not work with my case. I tried with the proposed alternative (listings) but the pdf output is even worse.
Ok. Might be worth setting a width
option anyway for str()
output. Otherwise, best that I know how to do is to leave it as is.
Currently working on it. There is no easy way currently but I found some tricks thanks to your code_chunk()
idea.
Some examples have text output that greatly extend far to the right. While it works online (scroll bars), it may not work for a book.
https://github.com/DivadNojnarg/outstanding-shiny-ui/blob/ba9293faeb17d142bd5d83dfe0cc72e62c64ad88/web-applications.Rmd#L209-L219
https://github.com/DivadNojnarg/outstanding-shiny-ui/blob/ba9293faeb17d142bd5d83dfe0cc72e62c64ad88/web-applications.Rmd#L292-L297