[R] Returning positions of a vector
Sundar Dorai-Raj
sundar.dorai-raj at pdf.com
Thu Jul 28 00:07:26 CEST 2005
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
More information about the R-help
mailing list