I think that you want to use 'grep' after converting the factors to
characters:

> tf = mydf[grep("TF", as.character(mydf$alfa)),]
> tf
     alfa   beta
2 TF13124 type_b
4  TF1234 type_g
6 TF13124 type_a
7 TF14333 type_g
9  TF1234 type_g
>



On 4/28/06, Albert Vilella <avilella@gmail.com> wrote:
>
> 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.
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



--
Jim Holtman
Cincinnati, OH
+1 513 646 9390 (Cell)
+1 513 247 0281 (Home)

What the problem you are trying to solve?

	[[alternative HTML version deleted]]

