And the plyr version of this would be (using DF as the data frame name)
## transform method, mapping length(runtime) to all observations
## similar to David's results:
library('plyr')
ddply(DF, .(time, partitioning_mode), transform, n = length(runtime))
# or equivalently, the newer and somewhat fa
Another package to consider, especially if your dataframe is large, is
'data.table':
> tp <- read.table(textConnection(" time partitioning_mode workload runtime
+ 1 1 shardingquery 607
+ 2 1 shardingquery 85
+ 3 1 shardingquery 52
+
<- cast(df, partitioning_mode + workload~time, value="runtime",
length)
> From: brave...@gmail.com
> Date: Sun, 23 Oct 2011 19:29:40 +0200
> To: r-help@r-project.org
> Subject: [R] summarizing a data frame i.e. count -> group by
>
>
On Oct 23, 2011, at 1:29 PM, Giovanni Azua wrote:
Hello,
This is one problem at the time :)
I have a data frame df that looks like this:
> df <-read.table(textConnection(" time partitioning_mode workload
runtime
+ 1 1 shardingquery 607
+ 2 1 shardingq
Hello,
This is one problem at the time :)
I have a data frame df that looks like this:
time partitioning_mode workload runtime
1 1 shardingquery 607
2 1 shardingquery 85
3 1 shardingquery 52
4 1 shardingquery
5 matches
Mail list logo