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, duration hours minute second in high quality that is uploaded to the channel Statistics Globe 05 August 2022. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 1,408 times and liked it 28 visitors.