[R] Google style

Duncan Murdoch murdoch at stats.uwo.ca
Mon Aug 31 19:00:33 CEST 2009


On 8/31/2009 11:50 AM, Mark Knecht wrote:
> On Mon, Aug 31, 2009 at 6:36 AM, Terry Therneau<therneau at mayo.edu> wrote:
> <SNIP>
>> The authors borrowed so much else from C, the semicolon would have been
>> good too.
> <SNIP>
> 
> I know real R coders will chuckle

I'd say cringe, rather than chuckle.  This is going to make you waste a 
lot of time some day, when you stare and stare at code like Terry's and 
can't figure out what's wrong with it:

	zed <- function(x,y,z) {
	       x + y
                  +z;
	      }

The value of the function is +z, not x+y+z, even though the C part of 
your brain made you type it that way and reads it as one statement in 
the body, not two.

Duncan Murdoch



  but I've taken to using semicolons
> just because it looks better to my eyes and let's my brain know where
> I think lines end. True, the language isn't checking for them but it
> keeps my typing consistent with the only other language I program in.
> (EasyLanguage)
> 
> plot(cumsum(T1$PL_SUM) ~ T1$MyDate, typ="l");
> lines(cumsum(Z1$PL_SUM) ~ Z1$MyDate, typ="l", col="green");
> lines(cumsum(Z2$PL_SUM) ~ Z2$MyDate, typ="l", col="red");
> lines(cumsum(Z3$PL_SUM) ~ Z3$MyDate, typ="l", col="purple");
> 
> While it's not supported today, maybe one day there could be a way it
> was? Who knows...
> 
> Cheers,
> Mark
> 
> ______________________________________________
> 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