Skip to content
Prev 82403 / 398502 Next

R coding style (was R is GNU S, not C....)

Please use an informative subject line.
On Wed, 7 Dec 2005 vincent at 7d4.com wrote:

            
Yes, those are the 'Bengtsson Coding Conventions'.  (He says 'our', but it 
appears to be a royal 'we'.)  Some contradict the primary documentation 
(e.g. for S3 generics where dispatch can usefully occur on particular 
named arguments), and the author seems unaware that underline is allowed 
in syntactic names (and is preferred to capitalization schemes by many).
I had already posted this in this thread: it is in sections 3.1 and 
Appendix B of `Writing R Extensions'.  (You seem unaware that this is a 
manual that ships with every copy of R, as you give a URL on CRAN for 
part of it.)

The style R itself uses to deparse code is canonical.  As in
+ abc=T;
+ 7+8;
+ }
function ()
{
     abc = T
     7 + 8
}

Voila, those distracting semicolons have disappeared! (R has removed the 
pointless empty statement which was specified at the end of the lines, 
between the semicolon and newline.)

Note how spaces are used to improve clarity.

Note that the use of T has not, as using T as a variable is legitimate R. 
The manual in 2.2.0 (but not 2.2.1 beta) says <- will be used for 
assignment, and indeed the equivalent _ was converted to <- whereas = is a 
different token (and postdates that manual section).  But it does say <- 
is preferred.

To quote:

   This tidied version is much easier to read, not least by other users
   who are used to the standard format.

and that is the main point, reinforced by Philippe's message.  If you are 
trying to communicate, make life easier for your readers.

Thread (33 messages)

shanmuha boopathy how to get or store the intermediate v?lues while running a function Dec 6 vincent@7d4.com how to get or store the intermediate v?lues while running a function Dec 6 Martin Maechler R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Adaikalavan Ramasamy R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Philippe GROSJEAN R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Adaikalavan Ramasamy R is GNU S, not C.... [was "how to get or store ....."] Dec 6 vincent@7d4.com R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Brian Ripley R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Xiaofan Li R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Jan T. Kim R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Peter Ehlers R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Barry Rowlingson R formatting Dec 6 Patrick Burns R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Peter Dalgaard R formatting Dec 6 Martin Maechler R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Barry Rowlingson R formatting Dec 6 vincent@7d4.com R is GNU S, not C.... [was "how to get or store ....."] Dec 6 (Ted Harding) R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Deepayan Sarkar R is GNU S, not C.... [was "how to get or store ....."] Dec 6 (Ted Harding) R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Patrick Connolly R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Philippe GROSJEAN R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Patrick Connolly R is GNU S, not C.... [was "how to get or store ....."] Dec 6 vincent@7d4.com R is GNU S, not C.... [was "how to get or store ....."] Dec 6 Peter Ehlers R is GNU S, not C.... [was "how to get or store ....."] Dec 7 Dave Roberts R is GNU S, not C.... [was "how to get or store ....."] Dec 7 Gabor Grothendieck R is GNU S, not C.... [was "how to get or store ....."] Dec 7 Jan T. Kim R is GNU S, not C.... [was "how to get or store ....."] Dec 7 Jim Lemon R is GNU S, not C.... [was "how to get or store ....."] Dec 7 Deepayan Sarkar R is GNU S, not C.... [was "how to get or store ....."] Dec 7 Brian Ripley R coding style (was R is GNU S, not C....) Dec 7 Martin Maechler R is GNU S, not C.... [was "how to get or store ....."] Dec 7 vincent@7d4.com R coding style (was R is GNU S, not C....) Dec 8