I tried
trip_weekday$day <- ordered(trip_weekday$day, levels = c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday","Saturday"))
but still the data frame was randomly arranged.
I tried
trip_weekday$day <- ordered(trip_weekday$day, levels = c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday","Saturday"))
but still the data frame was randomly arranged.
Your code left the dataframe as it was and just replaced the day column with a sorted version.
Try
trip_weekday<- trip_weekday[trip_weekday$day, levels = c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday","Saturday")],
I really like tidyverse where this would be:
trip_weekday <- trip_weekday %>% arrange(ordered(day, levels = c("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday","Saturday"))
Thank you soo much, It worked.
This topic was automatically closed 7 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.