Question about R code date and time

I am trying to execute the following code chunk:
all_tripdata$date <- as.Date(all_tripdata$started_at)

The goal is to format date and aggregate ride data for each month, day, or year.
Instead, I got the following error message:
Error in charToDate(x) :
character string is not in a standard unambiguous format
Could someone please help me solve this probleme

What format is all_tripdata$started_at in? If it is not in yyyy-mm-dd format, then you have to specify its format in as.Date. For instance, if your date is in mm/dd/yy format, then converting it to date would involve the following:

date <- "2/11/22"
newdate <- as.Date(date,"%m/%d/%y")

Hope this helps!

1 Like

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.