Re: [R] Returning positions of a vector

From: Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com>
Date: Thu 28 Jul 2005 - 08:07:26 EST

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

Try ?match.

x <- c(3, 1, 7, 4, 10)
match(c(10, 1, 4), x)

HTH, --sundar



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:11:26 2005

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