1 Jun 2009 01:32
Re: IP-Address
Henrik Bengtsson <hb <at> stat.berkeley.edu>
2009-05-31 23:32:56 GMT
2009-05-31 23:32:56 GMT
Not really, just the old saying that any piece of code can be made
twice as fast (which often holds true recursively). /Henrik
On Sun, May 31, 2009 at 1:58 PM, Wacek Kusnierczyk
<Waclaw.Marcin.Kusnierczyk <at> idi.ntnu.no> wrote:
> wow! :)
>
> vQ
>
> Henrik Bengtsson wrote:
>> library(gsubfn)
>> library(gtools)
>> library(rbenchmark)
>>
>> n <- 10000
>> df <- data.frame(
>> a = rnorm(n),
>> b = rnorm(n),
>> c = rnorm(n),
>> ip = replicate(n, paste(sample(255, 4), collapse='.'), simplify=TRUE)
>> )
>>
>> res <- benchmark(columns=c('test', 'elapsed'), replications=10, order=NULL,
>> peda = {
>> connection <- textConnection(as.character(df$ip))
>> o <- do.call(order, read.table(connection, sep='.'))
>> close(connection)
>> df[o, ]
>> },
>>
(Continue reading)
RSS Feed