On 06/11/03 03:28, Jonck van der Kogel wrote:
>Hi all,
>I have (yet another) question about a function in R. What I would like 
>to do is test for the presence of a certain value in a vector, and have 
>the positions that this value is at returned to me.
>For example, let's say I have a vector:
>x <- c(1,1,2,2,3,3,4,4)
>
>Now I would like a function that would return positions 3 and 4 should 
>I test for the value "2". Or 5 and 6 should I test for "3".

one way is
which(x==2)

I'm sure there are others.

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
R page:               http://finzi.psych.upenn.edu/

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to