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