Skip to content
Prev 167283 / 398502 Next

Efficiency challenge: MANY subsets

Try this one;  it is doing a list of 7000 in under 2 seconds:
+
+
+  c("M","G","L","W","I","S","F","G","T","P","P","S","Y","T","Y","L","L","I"
+ ,"M",
+
+
+  "N","H","K","L","L","L","I","N","N","N","N","L","T","E","V","H","T","Y","F",
"N","I","N","I","N","I","D","K","M","Y","I","H","*")
+  )
+   list(
+     c(1,22),c(22,46),c(46, 51),c(1,46),c(22,51),c(1,51)
+   )
+  )
+ fragments <- lapply(indexes, function(.seq){
+     lapply(.seq, function(.range){
+         .range <- seq(.range[1], .range[2])  # save since we use several times
+         lapply(sequences, '[', .range)
+     })
+ })
+ })
   user  system elapsed
   1.24    0.00    1.26
On Fri, Jan 16, 2009 at 3:16 PM, Johannes Graumann
<johannes_graumann at web.de> wrote: