Use ?plyr::ddply

---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnew...@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.

Hongwei Dong <pdxd...@gmail.com> wrote:

Hi, R users, I'm wondering how I can aggregate data in R with different 
functions for different columns. For example: x<-rep(1:5,3) 
y<-cbind(x,a=1:15,b=21:35) y<-data.frame(y) I want to aggregate "a" and "b" in 
y by "x". With "a", I want to use function "mean"; with "b", I want to use 
function "sum". I tried: > aggregate(y,x,mean(y$a),sum(y$b)) But I got the 
error: Error in match.fun(FUN) : 'mean(y$a)' is not a function, character or 
symbol Anyone can tell me how to fix this problem? Thanks. Gary   [[alternative 
HTML version deleted]]_____________________________________________
R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help 
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 
and provide commented, minimal, self-contained, reproducible code. 


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to