I've read other articles, such as:
Selecting rows where a column has a string like 'hsa..' (partial string match)
How do I select variables in an R dataframe whose names contain a particular string?
Subset data to contain only columns whose names match a condition
but most of them are simple fix:
- they only have one string to match
- they only have one partial string to match
so im here to ask for help.
lets say we have a sample data table like this:
sample = data.table('Feb FY2016', 50)
sample = rbind(sample, list('Mar FY2017', 30))
sample = rbind(sample, list('Feb FY2017', 40))
sample = rbind(sample, list('Mar FY2016', 10))
colnames(sample) = c('month', 'unit')
how can i subset the data so that my data contains only the rows who's "month" column satisfy following requirements:
- has year of 2016
- start with either 'Mar' or 'Feb'
Thanks!