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, wrote: >> >> On 2/15/11 4:35 PM, "Gabor Grothendieck" wrote: >> >>>I think the real good programming practice is to have a s

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 >

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 Gabor Grothendieck
On Tue, Feb 15, 2011 at 5:43 PM, wrote: > > On 2/15/11 4:35 PM, "Gabor Grothendieck" 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 muc

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 Grothendieck" 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 mak

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" 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 the body in a huge

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 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 >> contributed ones

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 wrote: > For those of you "familiar with R", here's a little quiz.  What what'

Re: [Rd] Reference classes and ".requireCachedGenerics"

2011-02-15 Thread John Chambers
PS: this is another glitch that arises when you don't use NAMESPACE files. If the .requireCachedGenerics is in a NAMESPACE and not exported, the conflict does not arise. On 2/15/11 12:52 PM, John Chambers wrote: No worries, and we will get rid of the warning message. Certain of the S4 classe

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 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 wrote: > On Wed, 16 Feb 2011, David Scott wrote: > >> 4. We don't

Re: [Rd] Using rasterImage on a CairoWin device prevents adding further elements to device?

2011-02-15 Thread Simon Urbanek
Joris, I have added raster support only recently (last week ;)) and there was a bug causing what you see. I have fixed it now so Cairo 1.4-7 will have the fix. Thanks, Simon On Feb 15, 2011, at 9:48 AM, Joris Meys wrote: > I was pointed to the Cairo package for plotting PNG images on a > devi

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 mis

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 s

Re: [Rd] Reference classes and ".requireCachedGenerics"

2011-02-15 Thread John Chambers
No worries, and we will get rid of the warning message. Certain of the S4 classes require methods for particular primitive functions. If a subclass of one of those classes is loaded from a package, then we need to turn on method dispatch for the corresponding primitive(s). For efficiency, th

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 im

Re: [Rd] gList and gTree methods of grid::grobX

2011-02-15 Thread baptiste auguie
Hi, Thanks for the clarification. Perhaps something along those lines could be added to the help page. Regards, baptiste On 15 February 2011 19:51, Paul Murrell wrote: > Hi > > baptiste auguie wrote: >> >> Dear all, >> >> In an attempt to draw fill patterns in grid graphics, I have >> encounte

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 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 > surpris

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 addit

Re: [Rd] gList and gTree methods of grid::grobX

2011-02-15 Thread Paul Murrell
Hi baptiste auguie wrote: Dear all, In an attempt to draw fill patterns in grid graphics, I have encountered a behavior of grobX that I cannot understand from the documentation. Consider this, library(grid) ## gTree g1 <- gTree(children=gList( rectGrob(0.5,0.5, width=unit(0.8,"np

Re: [Rd] matrixStats: Extend to arrays too (Was: Re: Suggestion: Adding quick rowMin and rowMax functions to base package)

2011-02-15 Thread Hadley Wickham
> A well-designed API generalized to work with arrays should probably > borrow ideas from how argument 'MARGIN' of apply() works, how argument > 'dim' in rowSums() for (though I must say the letter seem a bit ad hoc > at first sight given the name of the function).  There may also be > something to

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 thoughts

[Rd] matrixStats: Extend to arrays too (Was: Re: Suggestion: Adding quick rowMin and rowMax functions to base package)

2011-02-15 Thread Henrik Bengtsson
Hi. On Sun, Feb 13, 2011 at 10:18 AM, TakeoKatsuki wrote: > > Hi Henrik, > > It would be nice if functions of the matrixStats package can handle array > data. > For example, rowSums() of the base package sums along the third axis of an > array by rowSums(x, dim=2). That is a good idea. This was

[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. In

[Rd] Reference classes and ".requireCachedGenerics"

2011-02-15 Thread Jon Clayden
Dear all, If I load a package which creates reference classes whilst another such package is also loaded, I get a warning about masking of the ".requireCachedGenerics" variable. (FWIW, both packages are lazy-loaded.) Googling this variable name turned up only one previous discussion, which didn't

Re: [Rd] R 2.13.0 on Windows: R CMD check and '"du"' not found

2011-02-15 Thread Henrik Bengtsson
On Sun, Feb 13, 2011 at 5:30 AM, Duncan Murdoch wrote: > On 11-02-12 4:57 PM, Henrik Bengtsson wrote: >> >> FYI, I'm sure the following is a temporary issue, but in case it slips >> through, I want to raise it here.  On Windows 7 64-bit, running Rcmd >> check on R devel gives: > > I think you need

Re: [Rd] vignette question was: CRAN package sizes

2011-02-15 Thread Claudia Beleites
Please excuse the noise about dummy .Rnw. On 02/15/2011 03:44 PM, Claudia Beleites wrote: Also I started doing my homework with regards to package size, and that is mainly cleaning leftovers from vignette generation and compressing the pdfs. For most of my vignettes, ghostscript (lossy) compres

Re: [Rd] Google Summer of Code 2011 - credit where it is due

2011-02-15 Thread Prof. John C Nash
In my reminder that GSoC project proposals are requested (to R wiki developers' projects page for GSoC 2011), I mentioned that Dirk Eddelbuettel had acted as leader for the R Foundation activity on GSoC prior to handing the torch to Claudia Beleites and I for this year. I should have mentioned t

[Rd] Using rasterImage on a CairoWin device prevents adding further elements to device?

2011-02-15 Thread Joris Meys
I was pointed to the Cairo package for plotting PNG images on a device. I've been playing around with it, but found that after I use the rasterImage function, I can't add anything any more to the device, eg : img <- readPNG(system.file("img", "Rlogo.png", package="png")) r = as.raster(img[,,1:3])

[Rd] vignette question was: CRAN package sizes

2011-02-15 Thread Claudia Beleites
Also I started doing my homework with regards to package size, and that is mainly cleaning leftovers from vignette generation and compressing the pdfs. For most of my vignettes, ghostscript (lossy) compression works very well: I use the /screen settings and -dDownsampleColorImages=false gs -sDEV

Re: [Rd] S4 problems

2011-02-15 Thread Martin Morgan
On 02/14/2011 11:54 PM, robin hankin wrote: > Hello everybody > > [R-2.12.1] > > I am having difficulty dealing with Oarray objects. > I have a generic function, call it foo(), and I wish > to define a method for Oarray objects. > > I do not have or want a method for regular arrays [actually, >

Re: [Rd] readPNG gives warnings and doesn't execute sample code from help files

2011-02-15 Thread Ben Bolker
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/15/2011 08:44 AM, Joris Meys wrote: > Sorry, correction. X11() is not supposed to do that. So on Windows, > per-pixel alpha is no option apparently. Any chance this will be > implemented in the future? > > Cheers > Joris > > PS : also thx to Si

[Rd] ave reports warning when nothing is wrong

2011-02-15 Thread Gabor Grothendieck
ave reports a warning here: > DF <- data.frame(A = c(1, 2, 2), B = c(1, 1, 2), C = c(1, 2, 3)) > with(DF, ave(C, A, B, FUN = min)) [1] 1 2 3 Warning message: In FUN(X[[4L]], ...) : no non-missing arguments to min; returning Inf In this case it can be avoided by using drop = TRUE which could only

Re: [Rd] readPNG gives warnings and doesn't execute sample code from help files

2011-02-15 Thread Joris Meys
Sorry, correction. X11() is not supposed to do that. So on Windows, per-pixel alpha is no option apparently. Any chance this will be implemented in the future? Cheers Joris PS : also thx to Simon for his helpful answer earlier. On Tue, Feb 15, 2011 at 2:40 PM, Joris Meys wrote: > Thx again for

Re: [Rd] readPNG gives warnings and doesn't execute sample code from help files

2011-02-15 Thread Joris Meys
Thx again for your answer. I've tried X11() - which is supposed to support alpha per pixel as well, but on Windows that's still no avail. So basically, on Windows I can forget about alpha? Cheers Jors On Tue, Feb 15, 2011 at 2:20 PM, Ben Bolker wrote: > Joris Meys gmail.com> writes: > >> >> I b

Re: [Rd] readPNG gives warnings and doesn't execute sample code from help files

2011-02-15 Thread Ben Bolker
Joris Meys gmail.com> writes: > > I believed the standard plotting device on R in 2.12.1 would support > per-pixel alpha. It does support alpha, as > > plot(1:2,type="l") > polygon(c(1,1,2,2),c(1,2,2,1),col=rgb(60,100,60,60,maxColorValue=255)) > > plots correctly. Which device should I use t

[Rd] S4 problems

2011-02-15 Thread robin hankin
Hello everybody [R-2.12.1] I am having difficulty dealing with Oarray objects. I have a generic function, call it foo(), and I wish to define a method for Oarray objects. I do not have or want a method for regular arrays [actually, I want to coerce to an Oarray, and give a warning]. But setMet

[Rd] Google Summer of Code 2011

2011-02-15 Thread Prof. John C Nash
The 2011 Google Summer of Code will soon be open for organizations to submit potential projects for which students may apply (with detailed plans) for funding. We have some proposals in process at http://rwiki.sciviews.org/doku.php?id=developers:projects:gsoc2011 Note that projects do need to h

Re: [Rd] CRAN package sizes

2011-02-15 Thread Prof Brian Ripley
On Sun, 13 Feb 2011, Yihui Xie wrote: Regarding the reasons that make the doc directory large, I wonder if we can make some changes in R: 'we' cannot: only core developers can. However, end users can contribute in many other ways: see below. 1. Use a null graphics device as the default de

Re: [Rd] readPNG gives warnings and doesn't execute sample code from help files

2011-02-15 Thread Joris Meys
I believed the standard plotting device on R in 2.12.1 would support per-pixel alpha. It does support alpha, as plot(1:2,type="l") polygon(c(1,1,2,2),c(1,2,2,1),col=rgb(60,100,60,60,maxColorValue=255)) plots correctly. Which device should I use then? Cheers Joris On Mon, Feb 14, 2011 at 5:30

[Rd] gList and gTree methods of grid::grobX

2011-02-15 Thread baptiste auguie
Dear all, In an attempt to draw fill patterns in grid graphics, I have encountered a behavior of grobX that I cannot understand from the documentation. Consider this, library(grid) ## gTree g1 <- gTree(children=gList( rectGrob(0.5,0.5, width=unit(0.8,"npc"), he