How does RStudio determine the width of the console, and why does it seem like it's constantly erroneous?

I just discovered wid <- options()$width in RStudio, and it seems to be the source (or rather, much closer to the source) of a lot of annoyance in my everyday use of the console. I have to say that I am now on R 3.2.2, RStudio 0.99.491, on Linux Mint 17.3 (built on Ubuntu 14.04.3 LTS)

As I understand it, wid should be measured in characters - if wid is 52, say, then you should be able to put the alphabet on the screen twice (given the default font with a fixed width), but it does not look like this:

width versus actual width discrepancy

As you can see, despite the fact that wid is 52, I am unable to match the alphabet twice - I am typing 6 characters. I also note that this means that this is not only due to the presence of the command line arrow and space ( > ).

The problem seems somewhat proportional - if I have a wid up to 78, I can only match 70 characters; up to 104, 93, so wid about 88% pretty stable (side note: this also suggests that my assumption wid is measured in characters is probably correct).

The problem that this gives rise to is that often the overflow of the console output goes beyond its intended line, which makes the output ugly and difficult to digest; take, for example, a simple cut-off setDT(lapply(1:30, function(x) 1:3))[] , which produces for me:

whoops

It seems to me that the result was made on the width of the screen, which was not available in practice - a larger screen width was used for internal printing than actually.

This leaves me with three questions:

  • How is options()$width defined?
  • Why is this so inappropriate?
  • What can we do to override this error?
+5
source share
1 answer

A report was found of this in Rstudio support , and the problem seems to be related to high DPI; fixed bug fix in RStudio version 0.99.878 (released only today! how lucky), in accordance with the release notes :

Bug fixes

...

  • Proper calculation of getOption("width") on high DPI displays

Hope this helps someone else experience it! I was tempted to post this on / r / oddlysatisfying B -)

I would like to see the corresponding commit on the RStudio GitHub page if someone can track it (I’m out of luck).

+1
source

Source: https://habr.com/ru/post/1242586/


All Articles