How do we select a range of dates in a column?

You might want to check they are being recognized as valid dates first. What does class(covid$date) return?

I would try converting the date before your filtering steps:

  covid <- read.csv(file = 'covid_au_state.csv')
  covid$date <- as.Date(covid$date,'%d/%m/%y') 
  filt1 <- between(covid$date, '2020-03-17', '2020-08-16')
  data1 <- filter(covid, date <  '2020-03-17')

I also made an adjustment to the format of the dates on the filters because I believe once the date gets converted you'd want to use that format instead.

If that doesn't work I'd be happy to help troubleshoot more, but having a reproducible example would make things a lot easier, you can find out how to make one here: FAQ: What's a reproducible example (`reprex`) and how do I do one?

1 Like