Today I learned

Making dates more difficult

Author

Kevn Gilds, MPA

Published

2023-01-02

Dates are hard

I was making more difficult. I need to extract the month from dates submitted.

test_date <- session_summary %>% 
  dplyr::mutate(date = as.Date(date)) %>% 
  dplyr::mutate(date = lubridate::ymd(date)) %>% 
  dplyr::mutate(month = lubridate:: month(date, label = TRUE))

The worst is when the code runs and appears correct but is not.

Turns out I was making the process too difficult here is the code chunk that worked.

play_session <- session_summary %>% 
  dplyr::mutate(new_date = lubridate::mdy(date)) %>%
  dplyr::mutate(month = lubridate:: month(new_date, label = TRUE))

Maybe not optimized but it worked.

Until next time, cheers!


About

Kevin is a nonprofit data professional operating out of Lakeland, Florida.
My expertise is helping nonprofits collect, manage and analyze their program data.