Hi, nice to be part of this community.... I would appreciate very much help with DATE management. Currently I have a tibble with a date variable with the format "2015-01-01 08:10:00 AM" (YYYY-MM-DD HH:MM:SS).
I need to extract Year, Month, Day and Hours and include them as separate variables in 4 different new columns. Could you please give me a hint of how to code for it ? Thank you very much....Alejandro.
You can use tidyr::separate()
see this example
library(tidyverse)
sample_df <- data.frame(
date = c("2015-01-01 08:10:00 AM")
)
sample_df %>%
separate(date, into = c("year", "month", "day", "hour"), extra = "drop")
#> year month day hour
#> 1 2015 01 01 08
Created on 2020-04-29 by the reprex package (v0.3.0)
If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.
1 Like
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.