I have a data frame :
$Date, $name, $value
1949-05-01, Hurricane, 5
1950-02-01, Hurricane, 6
1950-03-01,
1950-04-01,
1950-05-01,
1951-02-01,
1951-03-01,
1951-04-01,
These dates go all the way to 2015, with measurements for months 02, 03,04 and 05. I am trying to create a dataframe, or subset of this data that only has the rows that are for April (04). I have tried some code such as
aprilSWE <- hurricane.df[grep("^04", hurricane.df$Date),]
But I am not sure if I am using the ^
correctly. As the month "04" is in the middle of the date string, how can I use wildcards to select any row that has a "04" in the month as the date?
Thanks!