Hi, I'd like to return the rows of sampled values of a vector. Can't figure out how to do it. For example: I start with [3, 1, 7, 4, 10] that have position [1,2,3,4,5]. I sample [10,1,4] and I want to return [5,2,4]. I'm sure there's a simple way to do that but haven't been able to figure it out or locate it. Thanks in advance...mj [[alternative HTML version deleted]]
On 7/27/05 5:44 PM, "Mike Jones" <MikeJones@westat.com> wrote:> Hi, > > I''d like to return the rows of sampled values of a vector. Can''t figure > out how to do it. > > For example: I start with [3, 1, 7, 4, 10] that have position > [1,2,3,4,5]. I sample [10,1,4] and I want to return [5,2,4]. > > I''m sure there''s a simple way to do that but haven''t been able to figure > it out or locate it. > > Thanks in advance...mjLook at ?match:> junk <- c(3,1,7,4,10) > junk1 <- c(10,1,4) > match(junk1,junk)[1] 5 2 4 Hope that helps.... Sean [[alternative HTML version deleted]]
Mike Jones wrote:> Hi, > > I'd like to return the rows of sampled values of a vector. Can't figure > out how to do it. > > For example: I start with [3, 1, 7, 4, 10] that have position > [1,2,3,4,5]. I sample [10,1,4] and I want to return [5,2,4]. > > I'm sure there's a simple way to do that but haven't been able to figure > it out or locate it. > > Thanks in advance...mjTry ?match. x <- c(3, 1, 7, 4, 10) match(c(10, 1, 4), x) HTH, --sundar