On 13/12/2009 5:22 PM, Carl Witthoft wrote:
Duncan Murdoch wrote:
"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."
I have to disagree here. Soft-wrapping is the default option in most
editors, and the OSX R.app gui wraps both input and output. It's pretty
easy to tell a bunch of code is (or isn't) all one line unless you don't
believe in prompts or something :-).
Try this in the OSX GUI (or any other editor that does soft wrapping).
Open a "New Document", and make the window pretty narrow, e.g. about
10-20 chars wide. (You can make it wider, but you'll have more typing
below.)
Type this line into it, with enough ones that it wraps to 3 lines:
x <- 111111111111111
It will look something like this in the GUI.
x <-
11111111111111
1
Other editors might wrap differently, e.g. vi pays no attention to
whitespace, and just wraps the characters when it hits the end of the line.
Now put a hard return before the 1 on the third line. It will look
almost identical, but (in the GUI editor) you'll see that the third line
now has a line number 2. It's a bit hard to see, but I wouldn't complain.
Now copy and paste the whole thing into the console. If the console is
also narrow enough, it will look the way I've typed it above, with
nothing at all to signal it's really two lines, not 1 or 3, until you
hit enter to execute both lines.
This is fine in languages like C where newlines barely matter, but it
makes a big difference whether that's one line or two in R.
So I'd say the best practice is to keep your lines short enough that you
never have your editor wrapping things for you, and to use editors that
give strong visual signals (e.g. the Windows GUI's $ signs, or the OSX
GUI editor's line numbering) when you accidentally violate this rule.
Duncan Murdoch
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.