R/R_multiGrep.r

Defines functions multiGrep

#xx=c("a","b","c")
#yy=c("a","dd","b","x","xc")

multiGrep=function(xx,yy,SORT=F){

       out=NULL
       for(u in 1:length(xx)){

              tm1=xx[u]
              tm2=grep(tm1,yy)
              if(u==1) out=tm2
              if(u>1) out=c(out,tm2)

       }# end of u loop

       out2=unique(out)
       if(SORT==T) out2=sort(out2)
       
       out2
       

}# end of multiGrep

#multiGrep(xx,yy)
#> multiGrep(xx,yy)
#[1] 1 3 5
#> xx
#[1] "a" "b" "c"
#> yy
#[1] "a"  "dd" "b"  "x"  "xc"

Try the CGEN package in your browser

Any scripts or data that you put into this service are public.

CGEN documentation built on April 28, 2020, 8:08 p.m.