filter data between two date period

how to write code in R, to filter data/rows between two date period

Example: I want to filter the data between 2000/01/01 and 2020/12/31

selected_movies %>%
select (adult, original_title, budget, genres, release_date, budget, revenue) %>%
filter ()

find_dates <- function(x) x > as.Date("2001/1/1") & x < as.Date("2021/1/1")
...
filter(find_dates(release_date)

should work, but not tested because no reprex. See the FAQ: How to do a minimal reproducible example reprex for beginners.

filter(release_date >= as.Date("2000-01-01") & release_date <= as.Date("2020-12-3"))

Something like this should work for your problem.

If the filter include the the date 2000/01/01 and 2020/12/31, as an alternative you can use between().

filter(between(release_date, as.Date("2000-01-01"), as.Date("2020-12-31")))

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.