[R] entries that match a regexp

Albert Vilella avilella at gmail.com
Fri Apr 28 11:27:09 CEST 2006


Hi all,

I am trying to filter the element of a df that start with "TF", like
this:

alfa =
c(123221,"TF13124",41243,"TF1234",32414,"TF13124","TF14333",2134123,"TF1234")
beta =
c("type_a","type_b","type_a","type_g","type_d","type_a","type_g","type_a","type_g")
mydf = data.frame(alfa,beta)
mydf
tf = mydf[mydf$alfa %in% "TF",]

Shouldn't the %in% operator to the trick here?

Thanks in advance,

    Albert.




More information about the R-help mailing list