Unable to Substract two columns in R

Still on my phone so haven't tested this code but something like this is what I'm describing

library(lubridate)
Cycling_Months$ride_length <- ymd_hms(Cycling_Months$ended_at) - ymd_hms(Cycling_Months$started_at)

Need you to check in those dates stamps that month comes before day because I can't be sure from that snippet. If it goes year, day, month, then the function you would want is ydm_hms

Edit: correction to lubridate function. Should have been ymd_hms, thanks to @startz

2 Likes