I just discovered wid <- options()$width
in RStudio, and it seems to be the source (or rather, much closer to the source) of much irritation in my everyday console usage. I should say up front that I'm currently on R 3.2.2, RStudio 0.99.491, on Linux Mint 17.3 (built over Ubuntu 14.04.3 LTS)
As I understand it, wid
should be measured in characters -- if wid
is equal to 52, say, then one should be able to fit the alphabet on the screen twice (given the fixed-width default font), but this doesn't appear to be the case:
As you can see, despite having wid
equal to 52, I am unable to fit the alphabet twice -- I come up 6 characters short. I also note that this means it is not simply due to the presence of the command prompt arrow and space (>
).
The problem seems somewhat proportional -- if I have wid
up to 78, I can only fit 70 characters; up to 104, 93, so wid
is about 88% off pretty consistently (side note: this also suggests my assumption wid
is measured in characters is probably right).
The problem that this engenders is that oftentimes console output overflows beyond its intended line, making the output ugly and hard to digest; take, for example, the simple snipped setDT(lapply(1:30, function(x) 1:3))[]
which produces for me:
It seems clear to me that the output was attempted on a screen width which was not available in practice -- that internally, a larger screen width than actually exists was used for printing.
This leaves me with three questions:
options()$width
determined?Found a post about this on Rstudio support and it seems the issue has to do with high DPI Displays; there is a claimed bug fix in RStudio version 0.99.878 (released just today! as luck would have it), according to the release notes:
Bug Fixes
...
- Correct computation of
getOption(“width”)
on high DPI displays
Hope this helps anyone else experiencing this! I'm tempted to post about this on /r/oddlysatisfying B-)
Would love to see the relevant commit on the RStudio GitHub page if anyone can track it down (I had no luck).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With