[R] position of an element in a vector
Marc Schwartz
mschwartz at medanalytics.com
Thu Feb 13 23:00:37 CET 2003
>-----Original Message-----
>From: r-help-admin at stat.math.ethz.ch
>[mailto:r-help-admin at stat.math.ethz.ch] On Behalf Of Jason Bond
>Sent: Thursday, February 13, 2003 3:41 PM
>To: R-help at stat.math.ethz.ch
>Subject: [R] position of an element in a vector
>
>
>Hello. Sorry for the elementary post. I've looked through the
>documentation, but can't seem to find a function which allows one to
>extract the position of an element within a list...for example
>the position
>of the element 4 in the vector c(1,2,4,3,6) is 3. Thanks much
>for any help.
>
> Jason
Take a look at ?which.
For example:
> which(c(1,2,4,3,6) == 4)
[1] 3
Regards,
Marc
More information about the R-help
mailing list