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

Could someone please tell me how I should do this? The "match" function only returns the first position that a value is found at. Of course I could write my own function that loops through the vector and tests for the presence of each value manually but it seems likely that a function that does this is already present in R. No need to re-invent the wheel :-)

Thanks very much, Jonck

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

Reply via email to