[datatable-help] Using a data.table to perform a two-way lookup
Short, Tom
TShort at epri.com
Thu Apr 14 14:58:58 CEST 2011
> -----Original Message-----
> From: datatable-help-bounces at r-forge.wu-wien.ac.at
> [mailto:datatable-help-bounces at r-forge.wu-wien.ac.at] On
> Behalf Of Karl Ove Hufthammer
> Sent: Thursday, April 14, 2011 07:58
> To: mdowle at mdowle.plus.com
> Cc: datatable-help at r-forge.wu-wien.ac.at
> Subject: Re: [datatable-help] Using a data.table to perform a
> two-way lookup
>
> On Thu, 14 Apr 2011 09:02:08 +0100, Matthew Dowle
> <mdowle at mdowle.plus.com>
> wrote:
> > On Wed, 2011-04-13 at 04:04 -0700, Karl Ove Hufthammer wrote:
> >> I've tried to come up with a similar generated dataset and example
> code.
> >> The result is much faster than similar code on my real
> data set, but
> >> still shows (using 'Rprof') that 'levels<-' is the main
> bottle-neck,
> >> as
> about
> >> one third of the time is spent there. Here's the code.
> I've included
> both
> >> a tiny example to show how the function is supposed to work, and a
> larger
> >> and slower example (which is still pretty fast, about
> thirty seconds
> >> on my computer):
If you want to shave that 1/3 off, you can convert your factor columns
to integers, do your processing, then manually reapply factor levels
when your processing is all done.
- Tom
More information about the datatable-help
mailing list