[R] Google's R Style Guide

diegol diegol81 at gmail.com
Sat Aug 29 19:51:54 CEST 2009



Max Kuhn wrote:
> 
> Perhaps this is obvious, but Ive never understood why this is the
> general convention:
> 
>> An opening curly brace should never go on its own line;
> 
> I tend to do this:
> 
> f <- function()
> {
>   if (TRUE)
>     {
>       cat("TRUE!!\n")
>     } else {
>       cat("FALSE!!\n")
>     }
> }
> 

I favor your approach. BUT I add one more level of indentation. Your
function would look like:

f <- function()
  {
    if (TRUE)
      {
        cat("TRUE!!\n")
      } else {
        cat("FALSE!!\n")
      }
  }

This way I quickly identify the beginning of the function, which is the one
line at the top of the expression AND sticking to the left margin.
In your code you use this same indentation in the if/else construct. I find
it also useful for the function itself.

-----
~~~~~~~~~~~~~~~~~~~~~~~~~~
Diego Mazzeo
Actuarial Science Student
Facultad de Ciencias Económicas
Universidad de Buenos Aires
Buenos Aires, Argentina
-- 
View this message in context: http://www.nabble.com/Google%27s-R-Style-Guide-tp25189544p25204937.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list