[R] extraction from a list of vectors

About this list Date view Thread view Subject view Author view

From: Jeff Miller (jmiller@xcaliber.com)
Date: Mon 18 Jun 2001 - 08:10:26 EST


Message-ID: <1BDB01B13696D411BD6200D0B7C854EA22F9D9@chi-prd-mail1.xcaliber.com>


        Hi ,
        I know this should be easy, but I haven't figured out a fast way to
do it.
        I have a list of vectors: mylist <- list(vector1, vector2, ...,
vectorN).
        (The vectors are made of integers. They vary in length from about 1
to 10).
        I also have a vector of indices: myidx <- c( i1, i2, ..., iN).
        From these I'd like to make this: newvector <- c(vector1[i1],
vector2[i2], ..., vectorN[iN]).
        It's easy to do this using a for loop, but I need something that
will be fast for lists
        with lengths of about 100,000. I've thought about using lapply, but
don't see how I can use it with "myidx".
        Thanks in advance,
                Jeff Miller

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view

This archive was generated by hypermail 2b30 : Fri 22 Jun 2001 - 18:58:45 EST