Skip to content

use of ddply() within function

3 messages · Jeff Newmiller, Franckx Laurent

#
As the footer says, "provide commented, _minimal_, self-contained, reproducible code."
This is hardly "minimal" or reproducible.

Anyway, this probably ought to qualify as a plyr FAQ of some sort: don't use the summarise function as the FUN argument within a function. Define a named or anonymous function of your own as the help page for ddply describes. Too many layers of syntactic sugar are involved for summarise to work within a function.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
Franckx Laurent <laurent.franckx at vito.be> wrote:

            
#
Problem solved, thanks.
I've used this instead: COSTaux_AVCAR         <- ddply(CARaux,c("SC","YEAR"),.fun = function(xx){sum(xx[  ,costcarin])})




-----Original Message-----
From: Jeff Newmiller [mailto:jdnewmil at dcn.davis.CA.us]
Sent: donderdag 6 september 2012 14:56
To: Franckx Laurent; 'r-help at r-project.org'
Subject: Re: [R] use of ddply() within function

As the footer says, "provide commented, _minimal_, self-contained, reproducible code."
This is hardly "minimal" or reproducible.

Anyway, this probably ought to qualify as a plyr FAQ of some sort: don't use the summarise function as the FUN argument within a function. Define a named or anonymous function of your own as the help page for ddply describes. Too many layers of syntactic sugar are involved for summarise to work within a function.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
Franckx Laurent <laurent.franckx at vito.be> wrote:

            
________________________________
 VITO Disclaimer: http://www.vito.be/e-maildisclaimer