Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-16 Thread Martin Becker
On 15.02.2011 22:48, David Scott wrote: On 16/02/2011 7:04 a.m., Paul Johnson wrote: ... 4. We don't want gratuitous use of return at the end of functions. Why do people still do that? Well I for one (and Jeff as well it seems) think it is good programming practice. It makes explicit what

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-16 Thread Duncan Murdoch
On 11-02-16 7:31 AM, Martin Becker wrote: On 15.02.2011 22:48, David Scott wrote: On 16/02/2011 7:04 a.m., Paul Johnson wrote: ... 4. We don't want gratuitous use of return at the end of functions. Why do people still do that? Well I for one (and Jeff as well it seems) think it is good

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-16 Thread luke-tierney
If you evaluate return(x) in an evironment env then then that will execute a return from the function call associated with env or signal an error if there is none. That is the way return() is intended to work. Best, luke On Wed, 16 Feb 2011, Duncan Murdoch wrote: On 11-02-16 7:31 AM, Martin

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-16 Thread Martin Becker
Luke, thanks for your explanation. I now remember that I was indeed getting an error (instead of a silent abort) because I did something comparable to a .Call() to lapply in section 5.11 of WRE (Writing R extensions) where expr was the body of a function f (literally) which contained a

[Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Paul Johnson
Hello, I am looking for CRAN packages that don't teach bad habits. Can I have suggestions? I don't mean the recommended packages that come with R, I mean the contributed ones. I've been sampling a lot of examples and am surprised that many ignore seemingly agreed-upon principles of R coding.

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Hadley Wickham
I think my recent packages are pretty good. In particular, I'd recommend string, plyr and testthat as being well written, well documented and (somewhat) well tested. I've also been trying to write up the process of writing good packages. See https://github.com/hadley/devtools/wiki for my

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Jeffrey Ryan
I think for teaching, you need to use R itself. Everything else is going to be a derivative from that, and if you are looking for 'correctness' or 'consistency' with the spirit of R, you can only be disappointed - as everyone will take liberties or bring personal style into the equation. In

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Gabor Grothendieck
On Tue, Feb 15, 2011 at 1:04 PM, Paul Johnson pauljoh...@gmail.com wrote: Hello, I am looking for CRAN packages that don't teach bad habits.  Can I have suggestions? I don't mean the recommended packages that come with R, I mean the contributed ones.  I've been sampling a lot of examples

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Sebastian P. Luque
Hi Paul, You might want to post this to the teaching list (R-sig-teaching). I'd look at packages written by old-timers and R Core. I've also found that most Bioconductor packages follow the guidelines you mention and many other excellent habits very well. I agree with you that these are very

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread David Scott
On 16/02/2011 7:04 a.m., Paul Johnson wrote: Hello, I am looking for CRAN packages that don't teach bad habits. Can I have suggestions? I don't mean the recommended packages that come with R, I mean the contributed ones. I've been sampling a lot of examples and am surprised that many ignore

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Geoff Jentry
On Wed, 16 Feb 2011, David Scott wrote: 4. We don't want gratuitous use of return at the end of functions. Why do people still do that? Well I for one (and Jeff as well it seems) think it is good programming practice. It makes explicit what is being returned eliminating the possibility of

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Kevin Wright
For those of you familiar with R, here's a little quiz. What what's the difference between: f1 - function(){ a=5 } f1() f2 - function(){ return(a=5) } f2() Kevin Wright On Tue, Feb 15, 2011 at 3:55 PM, Geoff Jentry geoffjen...@hexdump.orgwrote: On Wed, 16 Feb 2011, David Scott

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Geoff Jentry
f1 - function(){ a=5 } The primary difference is that function 1 uses an incorrect assignment operator in an attempt to cause confusion ;) __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Jeffrey Ryan
f3 - function() { ( a - 5 ) } f4 - function() { a - 5 a } On my machine f1,f2, and f4 all perform approx. the same. The () in f3 adds about 20% overhead. Jeff On Tue, Feb 15, 2011 at 4:22 PM, Kevin Wright kw.s...@gmail.com wrote: For those of you familiar with R, here's a little quiz.  

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Gabor Grothendieck
On Tue, Feb 15, 2011 at 4:48 PM, David Scott d.sc...@auckland.ac.nz wrote: On 16/02/2011 7:04 a.m., Paul Johnson wrote: Hello, I am looking for CRAN packages that don't teach bad habits.  Can I have suggestions? I don't mean the recommended packages that come with R, I mean the

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Ken.Williams
On 2/15/11 4:35 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: I think the real good programming practice is to have a single point of exit at the bottom. I disagree, it can be extremely useful to exit early from a function. It can also make the code much more clear by not having 95% of

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread David Scott
On 16/02/2011 11:43 a.m., ken.willi...@thomsonreuters.com wrote: On 2/15/11 4:35 PM, Gabor Grothendieckggrothendi...@gmail.com wrote: I think the real good programming practice is to have a single point of exit at the bottom. I disagree, it can be extremely useful to exit early from a

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Gabor Grothendieck
On Tue, Feb 15, 2011 at 5:43 PM, ken.willi...@thomsonreuters.com wrote: On 2/15/11 4:35 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: I think the real good programming practice is to have a single point of exit at the bottom. I disagree, it can be extremely useful to exit early from

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Duncan Murdoch
On 15/02/2011 5:22 PM, Kevin Wright wrote: For those of you familiar with R, here's a little quiz. What what's the difference between: f1- function(){ a=5 } This returns 5, invisibly. It's also bad style, according to those of us who prefer - to = for assignment. f2- function(){

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Steven McKinney
-Original Message- From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On Behalf Of Duncan Murdoch Sent: February-15-11 3:10 PM To: Kevin Wright Cc: R Devel List Subject: Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code On 15

Re: [Rd] Request: Suggestions for good teaching packages, esp. with C code

2011-02-15 Thread Ted Byers
From: r-devel-boun...@r-project.org [mailto:r-devel-boun...@r-project.org] On Behalf Of Gabor Grothendieck Sent: February-15-11 6:10 PM On Tue, Feb 15, 2011 at 5:43 PM, ken.willi...@thomsonreuters.com wrote: On 2/15/11 4:35 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: I think the real