[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 20:27:25 CET 2009


On 13/12/2009 1:30 PM, Viju Moses wrote:
> Thanks again to all for the persuasive expert statements. 
> 
> @ Duncan, I tried Rterm.exe as advised by you in the other post, hoping for
> my desired (soft wrapping) behavior. I didn't find it there either. 

Right, I rarely use it and didn't notice that.  Running "Rterm --ess" 
will give it to you, but it may have other undesirable side effects: 
that tells Rterm to assume Emacs is controlling things.

Duncan Murdoch

> 
> Shouldn't be difficult to get used to breaking lines manually, I guess.
> 
> Regards,
> 
> Viju
> 
> -----Original Message-----
> From: Ista Zahn [mailto:istazahn at gmail.com] 
> Sent: Sunday, December 13, 2009 23:48
> To: Viju Moses
> Cc: Jorge Ivan Velez; 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
> 
> Many applications have what is known as "soft wrapping", where the
> text wraps visually without inserting a new line. I don't use Windows,
> so I don't know if the R gui can do this or not, but I still maintain
> that the proper solution is to break your long input lines manually at
> places that both make syntactic sense and make the code easier to
> read.
> 
> -Ista
> 
> -----Original Message-----
> From: Duncan Murdoch [mailto:murdoch at stats.uwo.ca] 
> Sent: Sunday, December 13, 2009 23:51
> 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 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
> 
>




More information about the R-help mailing list