How to Convert Character String with AM & PM to Date & Time (R Example) | parse_date_time() Function

Опубликовано: 18 Январь 2023
на канале: Statistics Globe
411
13

How to remove AM and PM from a date and time object in the R programming language. More details: https://statisticsglobe.com/convert-c...
R code of this video:

my_dt <- c("5/02/2022 11:59:22 PM", # Create example dates & times
"7/12/2024 07:15:59 AM",
"3/10/2022 10:12:03 PM",
"5/09/2023 08:11:27 PM")
my_dt # Print example dates & times

class(my_dt) # Check class of data

install.packages("lubridate") # Install & load lubridate package
library("lubridate")

my_dt_new <- parse_date_time(my_dt, # Remove AM & PM from dates & times
"%d/%m/%y %I:%M:%S %p")
my_dt_new # Print updated dates

class(my_dt_new) # Check class of data

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