On Sep 8, 2011, at 03:18 , zhenjiang xu wrote:
> Thanks for all your replies. I am using rowsum() and it looks efficient. I
> hope I could do some benchmark sometime in near future and let people know.
> Or is there any benchmark result available?
I'm a bit surprised that no-one thought of xtabs
Thanks for benchmarking them. data.table is indeed worth looking at.
On Wed, Sep 7, 2011 at 9:55 PM, Dennis Murphy wrote:
> Hi:
>
> Here are a few informal timings on my machine with the following
> example. The data.table package is worth investigating, particularly
> in problems where its adva
Hi:
Here are a few informal timings on my machine with the following
example. The data.table package is worth investigating, particularly
in problems where its advantages can scale with size.
library(data.table)
dt <- data.table(x = sample(1:50, 100, replace = TRUE),
y = sam
Thanks for all your replies. I am using rowsum() and it looks efficient. I
hope I could do some benchmark sometime in near future and let people know.
Or is there any benchmark result available?
On Wed, Aug 31, 2011 at 12:58 PM, Bert Gunter wrote:
> Inline below:
>
> On Wed, Aug 31, 2011 at 9:50
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf Of Bert Gunter
> Sent: Wednesday, August 31, 2011 10:10 AM
> To: Henrique Dallazuanna
> Cc: r-help; zhenjiang xu
> Subject: Re: [R] how to create data.frames from vectors with duplicates
>
> For th
For the record, Henrique's use of rowsum() is about 10 times faster
than using tapply (and presumably anything with table() ) on my
computer. It call a C primitive.
-- Bert
On Wed, Aug 31, 2011 at 9:55 AM, Henrique Dallazuanna wrote:
> Try this:
>
> rowsum(x, y)
>
> On Wed, Aug 31, 2011 at 1:45
Inline below:
On Wed, Aug 31, 2011 at 9:50 AM, Jorge I Velez wrote:
> Hi Zhenjiang,
>
> Try
>
> table(unlist(mapply(function(x, y) rep(x, y), y, x)))
Yikes! How about simply tapply(x,y,sum) ??
?tapply
-- Bert
>
> HTH,
> Jorge
>
>
> On Wed, Aug 31, 2011 at 12:45 PM, zhenjiang xu <> wrote:
>
>> H
Also
tapply(x, y, sum)
HTH,
Jorge
On Wed, Aug 31, 2011 at 12:50 PM, Jorge I Velez <> wrote:
> Hi Zhenjiang,
>
> Try
>
> table(unlist(mapply(function(x, y) rep(x, y), y, x)))
>
> HTH,
> Jorge
>
>
> On Wed, Aug 31, 2011 at 12:45 PM, zhenjiang xu <> wrote:
>
>> Hi R users,
>>
>> suppose I have tw
On Aug 31, 2011, at 11:45 AM, zhenjiang xu wrote:
> Hi R users,
>
> suppose I have two vectors,
>> x=c(1,2,3,4,5)
>> y=c('a','b','c','a','c')
> How can I get a data.frame like this?
>> xy
> count
> a 5
> b 2
> c 8
>
> I know a few ways to fulfill the task. However, I have a huge
Try this:
rowsum(x, y)
On Wed, Aug 31, 2011 at 1:45 PM, zhenjiang xu wrote:
>
> Hi R users,
>
> suppose I have two vectors,
> > x=c(1,2,3,4,5)
> > y=c('a','b','c','a','c')
> How can I get a data.frame like this?
> > xy
> count
> a 5
> b 2
> c 8
>
> I know a few ways to fulfill
Hi Zhenjiang,
Try
table(unlist(mapply(function(x, y) rep(x, y), y, x)))
HTH,
Jorge
On Wed, Aug 31, 2011 at 12:45 PM, zhenjiang xu <> wrote:
> Hi R users,
>
> suppose I have two vectors,
> > x=c(1,2,3,4,5)
> > y=c('a','b','c','a','c')
> How can I get a data.frame like this?
> > xy
> cou
Hi R users,
suppose I have two vectors,
> x=c(1,2,3,4,5)
> y=c('a','b','c','a','c')
How can I get a data.frame like this?
> xy
count
a 5
b 2
c 8
I know a few ways to fulfill the task. However, I have a huge number
of this kind calculations, so I'd like an efficient solution. T
12 matches
Mail list logo