[R] lines don't wrap. must scroll horizontally to see/edit a long line in R GUI

Duncan Murdoch murdoch at stats.uwo.ca
Sun Dec 13 19:20:35 CET 2009


On 13/12/2009 12:43 PM, Viju Moses wrote:
> Thanks for responding. 
> 
> Problem: When I am typing a command, it does not wrap like it does in this
> email while typing. As I reach the right border, a horizontal scroll bar
> appears, and as I keep typing further, the initial part of the line starts
> disappearing below the left border of the console. So, I am unable to see a
> long line completely without moving the scroll bar right and left. R output,
> eg >1:120 (as discussed earlier), is wrapped fine. 
> 
> I find this difficult because I had been using R in Linux (terminal), now it
> is necessary for me to use it both in Windows and Linux. My first question
> was short because it is exactly the same as in the link I'd pasted. The
> purpose of this question is simply to ask how this can be changed. I
> understand it's a feature, not a bug. 
> 
> A screenshot of the R console is attached. Notice the $ on the left and the
> scrollbar below. 
> 
> Hope that's explanation enough. Looking forward to your reply. 

This is by design.  Carriage returns have syntactic meaning in R, so the 
editor shouldn't display phantom ones.  In Linux there's no choice 
because R doesn't control how text is displayed, but the Windows GUI 
gets it right.

Word wrapping in an email is different, because emails generally contain 
  text, not programs.  It becomes problematic when you see things like

  alongvariableanme <- anotherlongvariablename
+ 1

and you don't know how R would interpret it, because it might be either 
one or two statements.

Perhaps a smart wrapping algorithm could introduce line breaks only 
where they don't affect the meaning of the line, but then there would 
have to be statements that were unbreakable.

So my advice is simply to put your own line breaks into your code. 
Don't use an editor that wraps long lines unless it puts hard breaks 
between them.

Duncan Murdoch

> 
> 
> -----Original Message-----
> From: Duncan Murdoch [mailto:murdoch at stats.uwo.ca] 
> Sent: Sunday, December 13, 2009 16:35
> To: Viju Moses
> Cc: r-help at r-project.org
> Subject: Re: [R] lines don't wrap. must scroll horizontally to see/edit a
> long line in R GUI
> 
> On 12/12/2009 10:34 PM, Viju Moses wrote:
>> I'm facing this problem on R GUI version 2.10.0 on Windows Vista. I have
> not
>> changed Windows settings or R GUI settings much except to change from MDI
> to
>> SDI. 
>>
>> Someone else reported this problem a few months ago: 
>> https://stat.ethz.ch/pipermail/r-help/2009-April/195714.html
>> but it wasn't followed up. 
> 
> Yes it was, I replied to that message:
> 
>>> Which version are you talking about?  I don't recall Rgui ever wrapping 
>>> input.  The config settings affect output.  Maybe you're thinking of
> Rterm?
> 
> You also don't answer my question.  If you are claiming something has 
> changed, you need to tell us how to see the change.
> 
>




More information about the R-help mailing list