[R] Google's R Style Guide

Deepayan Sarkar deepayan.sarkar at gmail.com
Fri Aug 28 19:26:35 CEST 2009


On Fri, Aug 28, 2009 at 10:02 AM, Kevin Wright<kw.stat at gmail.com> wrote:
> On Fri, Aug 28, 2009 at 11:49 AM, Duncan Murdoch <murdoch at stats.uwo.ca>wrote:
>
>> On 8/28/2009 12:33 PM, Kevin Wright wrote:

[...]

>> Now that doesn't sound like the browser.  Whatever debugger you are using
>> has a bug.
>>
>> Duncan Murdoch
>>
>>
> Ah, right you are.  Thanks for the clarification.  This is not a "browser"
> phenomenon, but due to using "ess-eval-line-and-step" (which is a kind of
> cut and paste, I guess) to go through the code in emacs.  (Maybe there's a
> better way?)
>
> In any case, using "} else" eliminates the problem.

It might, but I tend to write my code with all curly braces (both open
and close) on their own line, and will keep doing so because I get to
choose my own style.

The important question is what the parser thinks. Here's a simplified example:

> bar <- function(x) { if (x) { TRUE } else { FALSE } }
> print(bar, useSource=FALSE)
function (x)
{
    if (x) {
        TRUE
    }
    else {
        FALSE
    }
}

So, R itself thinks that it's OK to have the else starting on it's own
line. This means that if you tried to edit 'bar' in ESS (using C-c
C-d, for example), you would end up in the same situation (at least
for functions for which source is not retained, which include package
functions).

-Deepayan




More information about the R-help mailing list