Re: [R] R is GNU S, not C.... [was "how to get or store ....."]

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Wed 07 Dec 2005 - 06:26:59 EST

Xiaofan Li wrote:
> I consistently use ";" at every end of my R code and have found it much more
> neat than those sentences without an end; for "<-" and "=", if I were the
> author I would rather take the first representation as a sign of
> passing-by-reference while the latter by value.

The problem with doing this is that it can be misleading. For example, you might think the following code does something different than what it does:

   x <- 1

       + 2 ;

which gives a result that might surprise you:

 > x <- 1
 > + 2 ;
[1] 2
 > x
[1] 1

You can argue that R's rules for marking the end of statements are rather bizarre and they should be different, but they aren't, and you shouldn't use a style of coding that suggests that they are.

Duncan Murdoch

>
> Xiaofan
>
> -----Original Message-----
> From: r-help-bounces@stat.math.ethz.ch
> [mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of McGehee, Robert
> Sent: 06 December 2005 16:32
> To: Jan T. Kim; rHelp
> Subject: Re: [R] R is GNU S, not C.... [was "how to get or store ....."]
>
>

>>Jan T. Kim wrote:
>>
>>There is a draft R Coding Convention available at
>>
>>    http://www.maths.lth.se/help/R/RCC/
>>
>>which may be useful for finding a style that is good because it is 
>>widely used and therefore familiar to a large number of readers.--

>
>
> However, as the author Henrik Bengtsson points out "these guidelines are
> ours and not the R-developers." Perhaps a definitive style guide published
> by R core that ensured consistency among new base code would be a helpful
> addition. I personally find the above style guide extremely useful when
> multiple programmers work on the same project, and would welcome a formal
> endorsement or revision by the R developers. (And despite Henrik's elegant
> guide, I too leave off the semicolons at the end of the lines.)
>
> --Robert
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.htmlde.html
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Dec 07 07:20:32 2005

This archive was generated by hypermail 2.1.8 : Wed 07 Dec 2005 - 09:36:59 EST