[R] Problem with Grep Under Loop

Gustaf Rydevik gustaf.rydevik at gmail.com
Mon Oct 6 14:28:33 CEST 2008


On Mon, Oct 6, 2008 at 2:16 PM, Gundala Viswanath <gundalav at gmail.com> wrote:
> Dear all,
>
> This is the sample of the source data (tab delimited)
>
> http://dpaste.com/82660/plain/
>
> - Gundala Viswanath
> Jakarta - Indonesia
>

Hi,

using this data, your original code works flawlessly - nothing to
correct. Perhaps you changed something between your original run and
this?

/Gustaf
-----------------------------------------------
> hm_acc <- c("XM_528056","AB002296")
> for (i in 1:length(hm_acc)){
+
+    hm_acc_id <- as.character(hm_acc[i])
+    print(hm_acc_id)
+
+    hm_allk <- grep(hm_acc_id,source$V1)
+    hm_all <- source[hm_allk,]
+
+    print(hm_all)
+ }
[1] "XM_528056"
          V1      V2   V3 V4      V5      V6         V7
13 XM_528056 panTro2 chr8  + 1775569 1896107 Chimpanzee
[1] "AB002296"
        V1      V2   V3 V4        V5        V6         V7
1 AB002296 panTro2 chr6  - 162615884 162626270 Chimpanzee
>





-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik



More information about the R-help mailing list