[R] Google's R Style Guide

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Aug 29 17:58:30 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 don't usually put one-liners in if/else blocks; here I would have
> used ifelse)


... where you certainly know that ifelse evaluates both cases (if and 
else) and hence might be less efficient for scalar valued problems?

Uwe Ligges


> I haven't seen many others format code in this way. Is there an
> objective reason for this (such as the rule for the trailing "}") or
> is this just aesthetics?
> 
> Thanks,
> 
> Max
> 
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list