Convert Year, Month, Day, Hour, Minutes & Seconds to Date & Time in R (3 Examples) | POSIXlt Class

Published: 05 August 2022
on channel: Statistics Globe
1,408
28

How to convert a character string to a date-time object in the R programming language. More details: https://statisticsglobe.com/convert-y...
R code of this video:

my_date <- "2023-10-07 11:38:55" # Create example date as character string
my_date # Print example date

my_date_1 <- as.Date(my_date) # Convert to Date class
my_date_1 # Print updated date

my_date_2 <- as.POSIXlt(my_date) # Convert to POSIXlt class
my_date_2 # Print updated date

my_date_unformatted <- "10-07-2023 11:38:55" # Create date with different format
my_date_unformatted # Print date with different format

my_date_3 <- strptime(my_date_unformatted, # Convert to POSIXlt class
format = "%m-%d-%Y %H:%M:%S")
my_date_3 # Print updated date

Follow me on Social Media:
Facebook – Statistics Globe Page:   / statisticsglobecom  
Facebook – R Programming Group for Discussions & Questions:   / statisticsglobe  
Facebook – Python Programming Group for Discussions & Questions:   / statisticsglobepython  
LinkedIn – Statistics Globe Page:   / statisticsglobe  
LinkedIn – R Programming Group for Discussions & Questions:   / 12555223  
LinkedIn – Python Programming Group for Discussions & Questions:   / 12673534  
Twitter:   / joachimschork  

Music by bensound.com


Watch video Convert Year, Month, Day, Hour, Minutes & Seconds to Date & Time in R (3 Examples) | POSIXlt Class online without registration, duration hours minute second in high quality. This video was added by user Statistics Globe 05 August 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,408 once and liked it 28 people.