Re: [R] Returning positions of a vector

From: Sean Davis <sdavis2_at_mail.nih.gov>
Date: Thu 28 Jul 2005 - 08:01:03 EST


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...mj

Look 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]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 28 08:05:19 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:34:06 EST