[R] Returning Non-Unique Index with Which (alternatives?)

David Winsemius dwinsemius at comcast.net
Tue Jan 13 04:34:34 CET 2009


 > sapply(qr, function (x) which(repo %in% x)
+ )
AAC ATT ATT
   3   6   6

On Jan 12, 2009, at 9:41 PM, Gundala Viswanath wrote:

> Dear all,
>
>
> I tried to find index in repo given  a query with this:
>
>> repo <- c("AAA", "AAT", "AAC", "AAG", "ATA", "ATT")
>> qr <- c("AAC", "ATT", "ATT")
>> which(repo%in%qr)
> [1] 3 6
>
>
> Note that the query contain repeating elements, yet
> the output of which only returns unique.
>
> How can I make it returning
>
> [1] 3 6 6
>
> instead?
>
>
> - Gundala Viswanath
> Jakarta - Indonesia
>
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list