Trying to get the whole of Viewing data frame organised by "Duration" time then saved as an xlsx file

library(janitor)
library(lubridate)
library(tidyverse)
library(readxl)
library(tidyquant)
library(openxlsx)
library(dplyr)
library("writexl")
install.packages("openxlsx", dependencies = TRUE)
library(openxlsx)
Viewing <- read_csv("ViewingActivity.csv")

Viewing %>%
  arrange(Duration)

openxlsx::write.xlsx(Viewing, "View3.xlsx")

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.

Please help or give tips. Thanks

The line Viewing %>% arrange(Duration) sorts the dataframe by ascending duration but does not save the result. Try Viewing <- Viewing %>% arrange(Duration).

Okay, that worked. Quite simple error.

Thanks