I want to use code similar to the above to save the dataframe "Viewing" and order the whole file by increasing or decreasing "Duration" time. Then I would like to save the file as an xlsx file.
The line Viewing %>% arrange(Duration) sorts the dataframe by ascending duration but does not save the result. Try Viewing <- Viewing %>% arrange(Duration).