[R] Sub-setting a data frame by partial column names?

barah pankajborah2k3 at rediffmail.com
Wed Nov 24 13:51:55 CET 2010


Hi Sarah,

Thanks a lot for the suggestion. It is working for me. 
subsetData<- bigData[,grep(partialName, colnames(bigData))]


But if i want to extract multiple columns along with the columns with
similar names, how do i that? Say the others column have similar values for
all the columns with similar partialnames. I tried the following

subsetData<- bigData[,grep("partialName", "Colname1", "Colname2",
colnames(bigData))]

It did not work.
Do you have any suggestion ?

Regards,

Pankaj Barah

-- 
View this message in context: http://r.789695.n4.nabble.com/Sub-setting-a-data-frame-by-partial-column-names-tp1577672p3057205.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list