DivadNojnarg / outstanding-shiny-ui

Outstanding User Interfaces with Shiny CRC Press book online version
https://unleash-shiny.rinterface.com
Other
224 stars 58 forks source link

Large print output #98

Closed schloerke closed 3 years ago

schloerke commented 3 years ago

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 Screen Shot 2021-07-11 at 3 46 17 PM

https://github.com/DivadNojnarg/outstanding-shiny-ui/blob/ba9293faeb17d142bd5d83dfe0cc72e62c64ad88/web-applications.Rmd#L292-L297 Screen Shot 2021-07-11 at 3 46 23 PM

DivadNojnarg commented 3 years ago

How would you solve this (appart from manually copying and rearranging the output)?

schloerke commented 3 years ago

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)

DivadNojnarg commented 3 years ago

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.

schloerke commented 3 years ago

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.

DivadNojnarg commented 3 years ago

Currently working on it. There is no easy way currently but I found some tricks thanks to your code_chunk() idea.