Gabor, Charles, Whit -- i've been walking the woods of R alone so far, and i
got to say that your replies to that trivial question are eye-opening
experience for me. Gentlemen, what i am trying to say in a roundabout way is
that i am extremely grateful and that you guys are frigging awesome.
Let
Looks like the rank function in R takes up most of the time.
Replacing it with a sum reduces the time of the rollapply solution to
one sixth of the its original time:
system.time(rollapply(z,len, function(x) rank(x)[len]))
user system elapsed
17.000.27 17.27
On Sun, 18 Apr 2010, zerdna wrote:
Gabor, Charles, Whit -- i've been walking the woods of R alone so far, and i
got to say that your replies to that trivial question are eye-opening
experience for me. Gentlemen, what i am trying to say in a roundabout way is
that i am extremely grateful and
library(fts)
x - fts(data=rnorm(1e6))
system.time(xrnk - moving.rank(x,500))
user system elapsed
0.680.000.68
you will have to disguise your data as a time series to use fts.
see below the exact implementation of rank that is used.
-Whit
templatetypename ReturnType
class
Could someone give me an idea on how to do rolling ranking, i.e. rank in the
moving window of last 100 numbers in a long vector? I tried naive solution
like
roll.rank-function(v, len){
r-numeric(length(v)-len+1)
for(i in len:length(v))
r[i-len+1]-rank(v[(i-len+1):i])[len]
r
I don't know if its any faster but you could try:
library(zoo)
z - zoo(v)
rollapply(z, len, function(x) rank(x)[len])
On Fri, Apr 16, 2010 at 4:21 PM, zerdna az...@yahoo.com wrote:
Could someone give me an idea on how to do rolling ranking, i.e. rank in the
moving window of last 100 numbers
On Fri, 16 Apr 2010, zerdna wrote:
Could someone give me an idea on how to do rolling ranking, i.e. rank in the
moving window of last 100 numbers in a long vector? I tried naive solution
like
roll.rank-function(v, len){
r-numeric(length(v)-len+1)
for(i in len:length(v))
7 matches
Mail list logo