On Oct 14, 2009, at 12:15 PM, Praveen Surendran wrote:

Hi,



Is there a command to get the indices of intersecting elements of two
vectors as intersect() will give the elements and not its indices.

?which


samp1 <- sample(seq(3,198, by=3), 20); samp2 <- sample(seq(3,198, by=3), 20)
 int <- intersect(samp1, samp2)
 int
#[1]  48  87   9 159  36   6  39 105
 which(seq(3,198, by=3) %in% int)
#[1]  2  3 12 13 16 29 35 53




Thanks in advance.



Praveen Surendran

School of Medicine and Medical Sciences

University College Dublin

Belfield, Dublin 4

Ireland.


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to