Separating columns

www.linkedin.com/in/francis-ngegba-740887287

I need help in separating columns as shown below:

year22$date <- as.Date(year22$started_at)
year22$year <- format(as.Date(year22$date), "%Y")
year22$month <- format(as.Date(year22$date), "%m")
year22$weekday <- wday(year22$date, label=TRUE)
year22$hour <- format(year22$started_at, format = "%H")

year22$ride_length <- (year22$ended_at - year22$started_at)
year22 <- year22 %>%
filter(ride_length > 0)

It keeps giving my errors as shown below:

Error in charToDate(x): character string is not in a standard unambiguous format
Traceback:

  1. as.Date(year22$started_at)
  2. as.Date.character(year22$started_at)
  3. charToDate(x)
  4. stop("character string is not in a standard unambiguous format")

Appreciated in advance for your help.

The error is caused by the attempted transformation

as.Date(year22$started_at)

because you are not telling as.Date() what the format is of the column started_at. Please post an example of what started_at looks like, making sure it is clear what represents the day and the month, and someone can help you set the format code of as.Date().

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.