I am using the package writexl to save two dataframe into one csv file in R shiny.
And here is part of my code:
library(writexl)
server <- function(input,output){
filename = function(){
paste('data.csv')
},
content = function(file){
df1 <- ...
df2 <- ...
write_xlsx(list(df1,df2), file)
}
)
this code works for me but do you know how to give a customized sheet name for df1 and df2? I don't want to change the package, would just want to use "write_xlsx", not the "write.xlsx"
Hi I just worked it out:
write_xlsx(list("sheet name1" = df1, "sheet name2" = df2), file)
Just name the data frames in the list and it should work.
write_xlsx(list(df1 = df1, df2 = df2), file)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With