[R] Extracting columns with specific string in their names

Jay josip.2000 at gmail.com
Mon Aug 22 16:33:43 CEST 2011


Hi,

Let's say that I have a set of column names that begin with the string
"Xyz". How do I extract these specific columns? I tried to do the
following:

dataframe1[,grep("Xyz",colnames(dataframe1))]

But it does not work. What is wrong with my expression?



More information about the R-help mailing list