Re: [R] Google's R Style Guide (has become S3 vs S4, in part)

2009-09-08 Thread Martin Maechler
Martin Morgan mtmor...@fhcrc.org on Tue, 01 Sep 2009 09:07:05 -0700 writes: spencerg wrote: Bryan Hanson wrote: Looks like the discussion is no longer about R Style, but S3 vs S4? yes nice topic rename! To that end, I asked more or less the same question a

Re: [R] Google's R Style Guide

2009-09-01 Thread Corrado
Thanks Duncan, Spencer, To clarify, the situation is: 1) I have no reasons to choose S3 on S4 or vice versa, or any other coding convention 2) Our group has not done any OO developing in R and I would be the first, so I can set up the standards 3) I am starting from scratch with a new package,

Re: [R] Google's R Style Guide

2009-09-01 Thread Duncan Murdoch
Corrado wrote: Thanks Duncan, Spencer, To clarify, the situation is: 1) I have no reasons to choose S3 on S4 or vice versa, or any other coding convention 2) Our group has not done any OO developing in R and I would be the first, so I can set up the standards 3) I am starting from scratch

Re: [R] Google's R Style Guide

2009-09-01 Thread Martin Morgan
Corrado wrote: Thanks Duncan, Spencer, To clarify, the situation is: 1) I have no reasons to choose S3 on S4 or vice versa, or any other coding convention 2) Our group has not done any OO developing in R and I would be the first, so I can set up the standards 3) I am starting from

Re: [R] Google's R Style Guide

2009-09-01 Thread Duncan Murdoch
On 9/1/2009 8:58 AM, Martin Morgan wrote: Corrado wrote: Thanks Duncan, Spencer, To clarify, the situation is: 1) I have no reasons to choose S3 on S4 or vice versa, or any other coding convention 2) Our group has not done any OO developing in R and I would be the first, so I can set up the

Re: [R] Google's R Style Guide

2009-09-01 Thread Gabor Grothendieck
On Tue, Sep 1, 2009 at 8:58 AM, Martin Morganmtmor...@fhcrc.org wrote: It seems relevant to compare S3 and S4 code for doing S3-style programming, leaving more 'advanced' S4 for another day. In S3 I might define a simple class and method as makeS3Foo -    function(x=numeric(), y=numeric())

Re: [R] Google's R Style Guide (has become S3 vs S4, in part)

2009-09-01 Thread Bryan Hanson
Looks like the discussion is no longer about R Style, but S3 vs S4? To that end, I asked more or less the same question a few weeks ago, arising from the much the same motivations. The discussion was helpful, here's the link:

Re: [R] Google's R Style Guide (has become S3 vs S4, in part)

2009-09-01 Thread spencerg
Bryan Hanson wrote: Looks like the discussion is no longer about R Style, but S3 vs S4? To that end, I asked more or less the same question a few weeks ago, arising from the much the same motivations. The discussion was helpful, here's the link:

Re: [R] Google's R Style Guide

2009-09-01 Thread Vitalie S.
On Tue, 01 Sep 2009 10:47:36 +0200, Corrado ct...@york.ac.uk wrote: Thanks Duncan, Spencer, To clarify, the situation is: 1) I have no reasons to choose S3 on S4 or vice versa, or any other coding convention 2) Our group has not done any OO developing in R and I would be the first, so I

Re: [R] Google's R Style Guide

2009-09-01 Thread Henrik Bengtsson
On Tue, Sep 1, 2009 at 6:29 AM, Duncan Murdochmurd...@stats.uwo.ca wrote: On 9/1/2009 8:58 AM, Martin Morgan wrote: Corrado wrote: Thanks Duncan, Spencer, To clarify, the situation is: 1) I have no reasons to choose S3 on S4 or vice versa, or any other coding convention 2) Our group has

Re: [R] Google's R Style Guide (has become S3 vs S4, in part)

2009-09-01 Thread Martin Morgan
spencerg wrote: Bryan Hanson wrote: Looks like the discussion is no longer about R Style, but S3 vs S4? yes nice topic rename! To that end, I asked more or less the same question a few weeks ago, arising from the much the same motivations. The discussion was helpful, here's the link:

Re: [R] Google's R Style Guide

2009-08-31 Thread David Scott
(Ted Harding) wrote: On 29-Aug-09 17:51:54, diegol wrote: 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)

Re: [R] Google's R Style Guide

2009-08-31 Thread baptiste auguie
2009/8/31 David Scott d.sc...@auckland.ac.nz I think this discussion is valuable, and have previously asked about style which I think is very important. Base R does suffer from very inconsistent naming and as I think Duncan said it makes it very difficult sometimes to remember names when

Re: [R] Google's R Style Guide

2009-08-31 Thread Romain Francois
Hi, Maybe the parser package can help you building such a code beautifier: require( parser ) data - attr( parser( /tmp/code.R ), data ) head( subset( data, terminal ), 5 ) line1 col1 byte1 line2 col2 byte2 token id parent token.desc terminaltext 1 10 0 1

Re: [R] Google's R Style Guide

2009-08-31 Thread Duncan Murdoch
baptiste auguie wrote: 2009/8/31 David Scott d.sc...@auckland.ac.nz I think this discussion is valuable, and have previously asked about style which I think is very important. Base R does suffer from very inconsistent naming and as I think Duncan said it makes it very difficult sometimes to

Re: [R] Google's R Style Guide

2009-08-31 Thread baptiste auguie
Considering these new insights from Romain and Duncan, a good project might be to revisit package.skeleton, using the parser package. This reminds me of a recent proposal of parsing Rd files to convert them into roxygen tags in the source code. Thanks for the input, baptiste 2009/8/31 Duncan

Re: [R] Google's R Style Guide

2009-08-31 Thread Vitalie S.
On Fri, 28 Aug 2009 16:40:53 +0200, Kevin Wright kw.s...@gmail.com wrote: On Fri, Aug 28, 2009 at 8:22 AM, Ted Harding ted.hard...@manchester.ac.ukwrote: On 28-Aug-09 12:59:24, Esmail wrote: Perhaps most of you have already seen this?

Re: [R] Google's R Style Guide

2009-08-31 Thread Tobias Verbeke
Vitalie S. wrote: On Fri, 28 Aug 2009 16:40:53 +0200, Kevin Wright kw.s...@gmail.com wrote: On Fri, Aug 28, 2009 at 8:22 AM, Ted Harding ted.hard...@manchester.ac.ukwrote: On 28-Aug-09 12:59:24, Esmail wrote: Perhaps most of you have already seen this?

Re: [R] Google's R Style Guide

2009-08-30 Thread Esmail
hadley wickham wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html thanks for sharing,

Re: [R] Google's R Style Guide

2009-08-29 Thread Esmail
Duncan Murdoch wrote: On 8/28/2009 8:59 AM, Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? The rules are mostly reasonable, though they aren't the ones followed in the R source. One bad

Re: [R] Google's R Style Guide

2009-08-29 Thread Esmail
(Ted Harding) wrote: On 28-Aug-09 12:59:24, Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I think it is grossly over-prescriptive. For example: function names have initial capital

Re: [R] Google's R Style Guide

2009-08-29 Thread Esmail
Kingsford Jones wrote: A few thoughts: ... -- It's nice that people have made these guides available Agreed .. it helps those relatively new to the language (and possible other language biases) get their orientation. Cheers, Esmail __

Re: [R] Google's R Style Guide

2009-08-29 Thread Esmail
Barry Rowlingson wrote: On Fri, Aug 28, 2009 at 5:11 PM, hadley wickhamh.wick...@gmail.com wrote: In my view, that's the purpose of indenting - you see scope from indenting. *cough* python *cough* :-) (my favorite language at the moment) __

Re: [R] Google's R Style Guide

2009-08-29 Thread Max Kuhn
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

Re: [R] Google's R Style Guide

2009-08-29 Thread hadley wickham
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) I haven't seen many others

Re: [R] Google's R Style Guide

2009-08-29 Thread Uwe Ligges
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

Re: [R] Google's R Style Guide

2009-08-29 Thread Corrado
I do not understand why one should use a S3 preferentially on a S4 class, if S4 is more rigorous. (The premiss is I am a newbie with OO programming in R, and would like to understand what is the proper way to OO program in R ) Regards On Saturday 29 August 2009 16:23:39 hadley wickham

Re: [R] Google's R Style Guide

2009-08-29 Thread Philippe Grosjean
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

Re: [R] Google's R Style Guide

2009-08-29 Thread spencerg
S3 is very easy to change; S4 is very difficult. This provides advantages and disadvantages for both. Some people swear by one and curse the other -- from both sides. S4 is newer, and I have had problems in the past finding out what S4 methods are available and finding

Re: [R] Google's R Style Guide

2009-08-29 Thread diegol
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) } }

Re: [R] Google's R Style Guide

2009-08-29 Thread Ted Harding
On 29-Aug-09 17:51:54, diegol wrote: 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 {

Re: [R] Google's R Style Guide

2009-08-29 Thread Duncan Murdoch
On 29/08/2009 12:03 PM, Corrado wrote: I do not understand why one should use a S3 preferentially on a S4 class, if S4 is more rigorous. As Spencer said, most people use either one or the other. I think it's generally a bad idea to mix them (there are strange semantics if you do that), so

Re: [R] Google's R Style Guide

2009-08-29 Thread John Sorkin
For my money, and perspective as one who has written a compiler, this reflects a failing of the R parser. Both if (TRUE) { cat(TRUE!!\n) } else { cat(FALSE!!\n) } and if (TRUE) { cat(TRUE!!\n) } else { cat(FALSE!!\n) } are easy to read, and should be accepted as

Re: [R] Google's R Style Guide

2009-08-29 Thread hadley wickham
But in interactive use the R parser is constrained to work a line at a time (unless it could predict what you were going to type next ;) Hadley On Sat, Aug 29, 2009 at 5:05 PM, John Sorkinjsor...@grecc.umaryland.edu wrote: For my money, and perspective as one who has written a compiler, this

Re: [R] Google's R Style Guide

2009-08-29 Thread Duncan Murdoch
On 29/08/2009 6:05 PM, John Sorkin wrote: For my money, and perspective as one who has written a compiler, this reflects a failing of the R parser. Both if (TRUE) { cat(TRUE!!\n) } else { cat(FALSE!!\n) } and if (TRUE) { cat(TRUE!!\n) } else { cat(FALSE!!\n) }

[R] Google's R Style Guide

2009-08-28 Thread Esmail
Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? Thanks, Esmail ps: Reminds me of PEP 8 for Python http://www.python.org/dev/peps/pep-0008/ Maybe not that surprising since Python is also one of

Re: [R] Google's R Style Guide

2009-08-28 Thread Peter Dalgaard
Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? The recommendation of variable.name over variable_name or variableName is contentious (to say the least) because of the clash with S3 method

Re: [R] Google's R Style Guide

2009-08-28 Thread Duncan Murdoch
On 8/28/2009 8:59 AM, Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? The rules are mostly reasonable, though they aren't the ones followed in the R source. One bad rule is the one on

Re: [R] Google's R Style Guide

2009-08-28 Thread Ted Harding
On 28-Aug-09 12:59:24, Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? Thanks, Esmail ps: Reminds me of PEP 8 for Python http://www.python.org/dev/peps/pep-0008/ Maybe not

Re: [R] Google's R Style Guide

2009-08-28 Thread Duncan Murdoch
On 8/28/2009 9:22 AM, (Ted Harding) wrote: On 28-Aug-09 12:59:24, Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? Thanks, Esmail ps: Reminds me of PEP 8 for Python

Re: [R] Google's R Style Guide

2009-08-28 Thread Thomas . Adams
Esmail, Very nice; thanks! Tom - Original Message - From: Esmail esmail...@gmail.com Date: Friday, August 28, 2009 8:59 am Subject: [R] Google's R Style Guide Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r- style.html

Re: [R] Google's R Style Guide

2009-08-28 Thread Kevin Wright
On Fri, Aug 28, 2009 at 8:22 AM, Ted Harding ted.hard...@manchester.ac.ukwrote: On 28-Aug-09 12:59:24, Esmail wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? Thanks, Esmail ps:

Re: [R] Google's R Style Guide

2009-08-28 Thread hadley wickham
Perhaps most of you have already seen this?  http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html Hadley -- http://had.co.nz/

Re: [R] Google's R Style Guide

2009-08-28 Thread Duncan Murdoch
On 8/28/2009 10:41 AM, hadley wickham wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html

Re: [R] Google's R Style Guide

2009-08-28 Thread Barry Rowlingson
On Fri, Aug 28, 2009 at 3:53 PM, Duncan Murdochmurd...@stats.uwo.ca wrote: On 8/28/2009 10:41 AM, hadley wickham wrote: Perhaps most of you have already seen this?  http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that

Re: [R] Google's R Style Guide

2009-08-28 Thread John Sorkin
I am troubled by the curly brace rule: An opening curly brace should never go on its own line and should always be followed by a new line; a closing curly brace should always go on its own line. It seems to me that the opening an dosing curly brace should go on their own lines to allow the

Re: [R] Google's R Style Guide

2009-08-28 Thread hadley wickham
I made my own version that reflects my personal biases: http://had.co.nz/stat405/resources/r-style-guide.html I see you repeated (or independently invented?) the bad rule about closing braces.  They should usually go on their own line, but not when followed by an else clause. That was an

Re: [R] Google's R Style Guide

2009-08-28 Thread Kevin Wright
On Fri, Aug 28, 2009 at 9:41 AM, hadley wickham h.wick...@gmail.com wrote: Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? I made my own version that reflects my personal biases:

Re: [R] Google's R Style Guide

2009-08-28 Thread Henrik Bengtsson
Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at: http://docs.google.com/View?id=dddzqd53_2646dcw759cb It's useful for beginners and those coding randomly. Like it or not. It's ok to try to persuade people coding randomly, but otherwise it is waste of time to get into

Re: [R] Google's R Style Guide

2009-08-28 Thread hadley wickham
It's ok to try to persuade people coding randomly, but otherwise it is waste of time to get into arguing over if-else or bracketing - we all have our own favorite. I totally agree. The main purpose of my style guide is so that my students write code that I can easily read, understand and

Re: [R] Google's R Style Guide

2009-08-28 Thread hadley wickham
An opening curly brace should never go on its own line and should always be followed by a new line; a closing curly brace should always go on its own line. It seems to me that the opening an dosing curly brace should go on their own lines to allow the reader to immediately know what is

Re: [R] Google's R Style Guide

2009-08-28 Thread Kevin Wright
On Fri, Aug 28, 2009 at 11:10 AM, Henrik Bengtsson h...@stat.berkeley.eduwrote: Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at: http://docs.google.com/View?id=dddzqd53_2646dcw759cb It's useful for beginners and those coding randomly. Like it or not. It's ok to

Re: [R] Google's R Style Guide

2009-08-28 Thread Erich Neuwirth
But if the closing curly brace marks the end of the if part of an if else statement, the else keyword has to be on the same line as the closing brace. The code will not work if the else is on the next line AFAIK. On Aug 28, 2009, at 6:11 PM, hadley wickham wrote: An opening curly brace

Re: [R] Google's R Style Guide

2009-08-28 Thread Duncan Murdoch
On 8/28/2009 12:33 PM, Kevin Wright wrote: On Fri, Aug 28, 2009 at 11:10 AM, Henrik Bengtsson h...@stat.berkeley.eduwrote: Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at: http://docs.google.com/View?id=dddzqd53_2646dcw759cb It's useful for beginners and those

Re: [R] Google's R Style Guide

2009-08-28 Thread Kevin Wright
On Fri, Aug 28, 2009 at 11:49 AM, Duncan Murdoch murd...@stats.uwo.cawrote: On 8/28/2009 12:33 PM, Kevin Wright wrote: On Fri, Aug 28, 2009 at 11:10 AM, Henrik Bengtsson h...@stat.berkeley.edu wrote: Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at:

Re: [R] Google's R Style Guide

2009-08-28 Thread Henrik Bengtsson
On Fri, Aug 28, 2009 at 9:10 AM, Henrik Bengtssonh...@stat.berkeley.edu wrote: Quite a while ago I put up R Coding Conventions (RCC) - a draft, now at:  http://docs.google.com/View?id=dddzqd53_2646dcw759cb Google Docs seems to have a hiccup when it comes to publishing/sharing docs; here is a

Re: [R] Google's R Style Guide

2009-08-28 Thread Barry Rowlingson
On Fri, Aug 28, 2009 at 5:11 PM, hadley wickhamh.wick...@gmail.com wrote: In my view, that's the purpose of indenting - you see scope from indenting. *cough* python *cough* Barry __ R-help@r-project.org mailing list

Re: [R] Google's R Style Guide

2009-08-28 Thread Deepayan Sarkar
On Fri, Aug 28, 2009 at 10:02 AM, Kevin Wrightkw.s...@gmail.com wrote: On Fri, Aug 28, 2009 at 11:49 AM, Duncan Murdoch murd...@stats.uwo.cawrote: On 8/28/2009 12:33 PM, Kevin Wright wrote: [...] Now that doesn't sound like the browser.  Whatever debugger you are using has a bug. Duncan

Re: [R] Google's R Style Guide

2009-08-28 Thread Duncan Murdoch
On 8/28/2009 1:02 PM, Kevin Wright wrote: On Fri, Aug 28, 2009 at 11:49 AM, Duncan Murdoch murd...@stats.uwo.ca mailto:murd...@stats.uwo.ca wrote: On 8/28/2009 12:33 PM, Kevin Wright wrote: On Fri, Aug 28, 2009 at 11:10 AM, Henrik Bengtsson h...@stat.berkeley.edu

Re: [R] Google's R Style Guide

2009-08-28 Thread Kingsford Jones
A few thoughts: -- As for naming preferences, in an interactive R session or answering an R-help question I'm glad I can type lm(log(y) ~ atan(x)) rather than FitLinearModel(CalculateNaturalLogarithm(y) ~ CalculateInverseTangent(x)) -- For consistency, their function makeColName(...) should