Re: [R] plyr workaround to converting by() to a data frame

From: <rmailbox_at_justemail.net>
Date: Thu, 07 Apr 2011 10:06:27 -0700

Is this what you are looking for?

ddply ( .variables = c("grp1", "grp2", "grp3" ), .data = df, .fun = plyr::summarize, abmin = min(c(a, b, c) ), abmax = max ( c ( a, b, c) ) )

Dear all
Is there a clean plyr version of the following by() and do.call(rbind, ...) construct:
> df<-data.frame(a=1:10,b=11:20,c=21:30,grp1=c("x","y"),grp2=c("x","y"),grp3=c("x","y"))
> dfsum<-by(df[c("a","b","c")], df[c("grp1","grp2","grp3")], range)
> as.data.frame(dfsum)
Error in as.data.frame.default(dfsum) :
  cannot coerce class '"by"' into a data.frame
> do.call(rbind, dfsum)

     [,1] [,2]
[1,] 1 29
[2,] 2 30

Thank you
Liviu

-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail

______________________________________________
R-help_at_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.

______________________________________________
R-help_at_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.
Received on Thu 07 Apr 2011 - 17:09:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 07 Apr 2011 - 17:10:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive