Monday, 15 March 2010

subset - R: Subsetting column 1 based on vector of values potentially present in column 2 -


I have a dataframe kegglist , which is the appropriate section that I show below:

  & gt; kegglist [131: 145,] V1 to V2 131 A0AVT1 hsa04120 132 A0PJZ3 hsa00514 133 A1A4S6 hsa05100 134 A1A4Y4 hsa05145 135 A1L167 hsa04120 136 A2RTX5 hsa00970 137 A3KFT3 hsa04740 138 A4D0S4 hsa05146 139 A4D0S4 hsa04512 140 A4D0S4 hsa04510 141 A4D0S4 hsa05200 142 A4D0S4 hsa05222 143 A4D0S4 hsa05145 144 A4D2G3 hsa04740 145 A5D8V6 hsa04144  

I also have a vector listx of V1 whatever happens, but not all, id is < Code> Kaglist :

  & gt; listx [1] A1L167 A2RTX5 A3KFT3 A4D0S4  

The subset I want to do kegglist $ V2 kegglist $ V1 Which are present in listx . Therefore, in this example, the result should look like this:

  & gt; Results [1] hsa04120 are hsa00970 hsa04740 hsa05146 hsa04512 hsa04510 hsa05200 hsa05222 hsa05145  

Please note that occur in real data, not listx in a row all ID < Code> kegglist $ V1 . Thanks for the cooperation

I tried

  Results & lt; -. Kegglist $ V1  
<[% listx kegglist $ V2%] p> No profit

After "div class =" text "itemprop =" Lesson ">

Try:. kegglist $ V2 [in kegglist $ V1%%

or: kegglist $ V2 [which is in% listx ($$ x1 $ kegglist)]


No comments:

Post a Comment