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.

______________________________________________
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.

Reply via email to