Re: [R] summarize dataframe based on multiple cols, not their combinations

2013-03-20 Thread arun
),lst1) res1[is.na(res1)]<-"*"  res1 #  mean n a b c #1   11 3 1 * * #2   12 3 * * 1 #3   14 3 * 1 * A.K. - Original Message - From: Alexander Shenkin To: r-help@r-project.org Cc: Sent: Wednesday, March 20, 2013 3:57 PM Subject: [R] summarize dataframe based on multiple

Re: [R] summarize dataframe based on multiple cols, not their combinations

2013-03-20 Thread Alexander Shenkin
ashen...@ufl.edu >> Sent: Wed, 20 Mar 2013 14:57:36 -0500 >> To: r-help@r-project.org >> Subject: [R] summarize dataframe based on multiple cols, not their >> combinations >> >> Hi folks, >> >> I'm trying to figure out how to get summarized data based on

Re: [R] summarize dataframe based on multiple cols, not their combinations

2013-03-20 Thread Alexander Shenkin
Nice, thanks Ista! On 3/20/2013 3:18 PM, Ista Zahn wrote: > How about > > library(reshape2) > mdf.m <- melt(my_df, measure.vars=c("a", "b", "c")) > mdf.m <- mdf.m[mdf.m$value > 0, ] > > ddply(mdf.m, "variable", function(x) c("mean"=mean(x$dat), "n"=nrow(x))) > > ? > > Best, > Ista > > On Wed,

Re: [R] summarize dataframe based on multiple cols, not their combinations

2013-03-20 Thread John Kane
Will this do? library(plyr) ddply(my_df, .(a), summarize, mm = mean(dat), number = length(dat)) John Kane Kingston ON Canada > -Original Message- > From: ashen...@ufl.edu > Sent: Wed, 20 Mar 2013 14:57:36 -0500 > To: r-help@r-project.org > Subject: [R] summarize dat

Re: [R] summarize dataframe based on multiple cols, not their combinations

2013-03-20 Thread Ista Zahn
How about library(reshape2) mdf.m <- melt(my_df, measure.vars=c("a", "b", "c")) mdf.m <- mdf.m[mdf.m$value > 0, ] ddply(mdf.m, "variable", function(x) c("mean"=mean(x$dat), "n"=nrow(x))) ? Best, Ista On Wed, Mar 20, 2013 at 3:57 PM, Alexander Shenkin wrote: > Hi folks, > > I'm trying to figur

[R] summarize dataframe based on multiple cols, not their combinations

2013-03-20 Thread Alexander Shenkin
Hi folks, I'm trying to figure out how to get summarized data based on multiple columns. However, instead of giving summaries for every combination of categorical columns, I want it for each value of each categorical column regardless of the other columns. I could do this with three different co