Hello,
I am a new R learner and I am working at the Cyclistic Bike case study. In the dataset there is the column "started_at" which is in the "MM/DD/YYYY HH:MM" format. The column is in the character format and I am trying to extract the date info into separate year, month, day columns. The following code chunk is what I am trying to run:
jan22 <- jan22 %>%
mutate(year = format(as.Date(started_at), "%Y")) %>%
mutate(month = format(as.Date(started_at), "%M")) %>%
mutate(date = format(as.Date(started_at), "%d")) %>%
mutate(day_of_week = format(as.Date(started_at), "%A")) %>%
mutate(ride_length = difftime(ended_at, started_at)) %>%
mutate(start_time = strftime(started_at, "%H"))
When I run the code I receive the following error:
Error in mutate()
:
! Problem while computing year = format(as.Date(started_at), "%Y")
.
Caused by error in charToDate()
:
! character string is not in a standard unambiguous format
Run rlang::last_error()
to see where the error occurred.
I am hoping someone can help me figure this out. Thus far I have not understood the Google solutions.