lgsf
1
Hello,
How do I convert the started_at and ended_at columns from a string to a date?
sapply(month1, class)
ride_id rideable_type started_at ended_at start_station_name
"character" "character" "character" "character" "character"
start_station_id end_station_name end_station_id start_lat start_lng
"character" "character" "character" "numeric" "numeric"
end_lat end_lng member_casual
"numeric" "numeric" "character"
Thanks,
LG
FJCC
2
The lubridate package has good functions for this. if the dates are currently shown in m/d/y format, the you could do
library(lubridate)
month1$started_at <- mdy(month1$started_at)
There is a dmy() function if they are in d/m/y format.
For more detailed help, please give more details about the date format.
lgsf
3
Hey FJCC,
The string is in UTC:
2021-01-09 14:39:33
Ultimately the goal is to calculate the difference of the times and create a ride_time column.
Thanks,
LG
FJCC
4
For that you would use
library(lubridate)
month1$started_at <- ymd_hms(month1$started_at)
lgsf
5
That worked perfectly. Thanks!
system
Closed
6
This topic was automatically closed 21 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.