[R] grep won't work finding one column

Kate Ignatius kate.ignatius at gmail.com
Tue Oct 14 16:23:55 CEST 2014


I'm having an issue with grep:

I have numerous columns that end with .at... when I use grep like so:

df[,grep(".at",colnames(df))]

it works fine.  When I have one column that ends with .at, it does not
work.  Why is that?  As this is loop with varying number of columns
ending in .at I would like some code that would work with 1 to n
number of columns.

Is there something more optimal than grep?

Thanks!



More information about the R-help mailing list