df change column from <chr> to <dttm> class | error NA after using lubridate

Hello All,
Sorry I need one more help I have below df
Rows: 1,048,575
Columns: 6
ride_id <chr> "762198876D69004D", "BEC9C9FBA0D4CF1B", "D2FD8EA432C77EC1", "54AE594E20B35881", "54025FDC7440B5~ started_at "7/9/2020 15:22", "7/24/2020 23:56", "7/8/2020 19:49", "7/17/2020 19:06", "7/4/2020 10:39", "7/~
ended_at <chr> "7/9/2020 15:25", "7/25/2020 0:20", "7/8/2020 19:56", "7/17/2020 19:27", "7/4/2020 10:45", "7/2~ start_station_id 180, 299, 329, 181, 268, 635, 113, 211, 176, 31, 142, 93, 31, 182, 182, 329, 334, 110, 30, 306,~
end_station_id <int> 291, 461, 156, 94, 301, 289, 140, 31, 191, 142, 31, 134, 142, 106, 110, 291, 157, 176, 177, 464~ member_casual "member", "member", "casual", "casual", "member", "casual", "member", "member", "member", "memb

and I want to change it like below

$ started_at 2020-01-21 20:06:59, 2020-01-30 14:22:39, 2020-01-09 19:29:26, 2020-01-06 16:17:07, 2020-01~

but I am not able despite using (lubridate ) with
suppressPackageStartupMessages({library(lubridate)}) but still have NAs
I try ymd_hms(x) and still have NAs

I am using the below version and machine
R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"Copyright (C) 2020 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit)

Thanks for support
M.Salah

It looks like the dates have the format m/d/y h:m, so convert them with the mdy_hm function from lubridate.

1 Like

yes it's work now
Rows: 1,048,575
Columns: 6
ride_id <chr> "762198876D69004D", "BEC9C9FBA0D4CF1B", "D2FD8EA432C77EC1", "54AE594E20B35881", "54025FDC7440B5~ started_at 2020-07-09 15:22:00, 2020-07-24 23:56:00, 2020-07-08 19:49:00, 2020-07-17 19:06:00, 2020-07-04~
ended_at <dttm> 2020-07-09 15:25:00, 2020-07-25 00:20:00, 2020-07-08 19:56:00, 2020-07-17 19:27:00, 2020-07-04~ start_station_id 180, 299, 329, 181, 268, 635, 113, 211, 176, 31, 142, 93, 31, 182, 182, 329, 334, 110, 30, 306,~
end_station_id <int> 291, 461, 156, 94, 301, 289, 140, 31, 191, 142, 31, 134, 142, 106, 110, 291, 157, 176, 177, 464~ member_casual "member", "member", "casual", "casual", "member", "casual", "member", "member", "member", "memb~

Thanks

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.