[R] grepping out columns

Kate Ignatius kate.ignatius at gmail.com
Wed Feb 18 21:27:36 CET 2015


Hi,

I've got a complicated grep problem (or not)...  I currently have a
file with the headings as follows:

DAY
MONTH
YEAR
SA_TUES
SA_MON
SU_WED
CH_TUES
CH_WED
CH_MON
AR_TUES
AR_WED
AR_MON
SA_THUR
SU_FRI
CH_THUR
CH_FRI
AR_THUR
AR_FRI

I want to grep out all columns that have SA at the beginning of their
day including any other information pertaining to that day.
Ultimately I want to end up with:

SA_TUES
SA_MON
CH_TUES
CH_MON
AR_TUES
AR_MON
SA_THUR
CH_THUR
AR_THUR

Is there a way of doing this simply with grep? Or will this need to be
more complicated?

Thanks!

K.



More information about the R-help mailing list