[R] Faster way to implement this search?
wandrson01 at gmail.com
Fri Mar 16 17:59:37 CET 2012
I am working on a simulation where I need to count the number of matches
for an arbitrary pattern in a large sequence of binomial factors. My
current code is
for(indx in 1:(length(bin.05)-3))
if ((bin.05[indx] == test.pattern) && (bin.05[indx+1] ==
test.pattern) && (bin.05[indx+2] == test.pattern))
return.values$count.match.pattern + 1
Since I am running the above code for each simulation multiple times on
sequences of 10,000,000 factors the code is taking longer than I would
like. Is there a better (more "R" way of achieving the same answer?
More information about the R-help