tapply(a$avg_cpc_1d, a$avg_pos, mean)
aggregate(avg_cpc_1d~avg_pos, a, mean)
clk_summ<-data.frame(group_by(clk2, OND)%>%summarise(cnt=n()))
a<-tapply(gp$txn,gp$product_ln_name,sum)
112
86
|
I have R data frame like this:
I need to get data frame in the following form:
Group number may vary, but their names and quantity could be obtained by calling
levels(factor(data$group))
What manipulations should be done with the data to get the result?
| ||||||||||||||||||||
closed as off-topic by gung, user777, kjetil b halvorsen, John, Peter Flom♦ Sep 11 '15 at 23:23
This question appears to be off-topic. The users who voted to close gave this specific reason:
| |||||||||||||||||||||
|
101
|
Here is the plyr one line variant using ddply:
Here is another one line variant using new package data.table.
This one is faster, though this is noticeable only on table with 100k rows. Timings on my Macbook Pro with 2.53 Ghz Core 2 Duo processor and R 2.11.1:
Further savings are possible if we use
setkey :
| ||||||||||||||||||||
|