[R] Google's R Style Guide

Duncan Murdoch murdoch at stats.uwo.ca
Fri Aug 28 15:49:19 CEST 2009


On 8/28/2009 9:22 AM, (Ted Harding) wrote:
> On 28-Aug-09 12:59:24, Esmail wrote:
>> Perhaps most of you have already seen this?
>>   
>> http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html
>> 
>> Comments/Critiques?
>> 
>> Thanks,
>> Esmail
>> 
>> ps: Reminds me of PEP 8 for Python
>> 
>>      http://www.python.org/dev/peps/pep-0008/
>> 
>> Maybe not that surprising since Python is also one of the main
>> languages used by Google.
> 
> I think it is grossly over-prescriptive. For example:
>   "function names have initial capital letters and no dots"
> is violated throughout R itself.

That is a style guide for code written within Google, it's not a general 
rule for the rest of us.  Internal style guides need to be prescriptive.

R itself is very inconsistent, and would be easier to use if it were 
more consistent. (For example, I can never remember the function name 
system.time, because we also have Sys.time, sys.parent, various names 
with underscores and with no punctuation, etc.)  Unfortunately, it's too 
late to change these now.

Since R has very few function names starting with capital letters, 
Google's choice is probably good:  it makes it easier when reading 
someone else's code to know whether the function is one they wrote, or 
one coming from R.  (I use a similar rule when writing LaTeX macros: 
mine usually begin with capital letters, because the standard ones 
almost never do.)

Duncan Murdoch




More information about the R-help mailing list