How to find max date and min date from a data frame column in R?

I have a data frame column that looks like this:

Creation_date
2018-1-22
2017-10-25
2016-12-26
2014-01-26
2018-02-15
2017-08-16

I would like to find the max date and the min date. How can I find that ?
Thanks in advance

Tagged:

Comments

  • Lets do it using lubridate package,
    dates <- data.frame(
    Creation_date = c("2018-1-22", "2017-10-25", "2016-12-26", "2014-01-26 "2018-2-15", "2017-08-16")
    )
    With data, we can easily perform the two necessary steps: convert to date format and summarize the information you want:

    load packages

    library(lubridate)
    library(dplyr)
    dates %>%
    # transform to date format with lubridate
    mutate(Creation_date = ymd(Creation_date )) %>%
    # find min and max
    summarise(min = min(Creation_date ),
    max = max(Creation_date ))

Sign In or Register to comment.