[Bioc-sig-seq] how to subset reads or seqs

Hervé Pagès hpages at fhcrc.org
Mon Sep 26 23:02:33 CEST 2011


Hi shan gao,

On 11-09-22 10:49 AM, wang peter wrote:
>     Hervé Pagès:
>
>     thank you very much
>
>     i think it is equal to the %in%

Not exactly. Using %in% ignores the order in which you are
supplying your ids:

   > x <- c(a=1, b=2, c=3)
   > myids <- c("c", "a")
   > x[names(x) %in% myids]  # NOT equivalent to x[myids]
   a c
   1 3
   > x[match(myids, names(x))]  # equivalent to x[myids]
   c a
   3 1

H.

>
> shan gao


-- 
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: hpages at fhcrc.org
Phone:  (206) 667-5791
Fax:    (206) 667-1319



More information about the Bioc-sig-sequencing mailing list