Export data from Rstudio to a new sheet in excisiting Excel file

can you guys help me to solve this problem: I want to export data into at new sheet in an already existing Excel file. Right now I have the following code:

openxlsx::write.xlsx(ft, file = "GME.xlsx", sheetName = period, append = TRUE)

When I run this code it just created an Excel file, but I can't seem to make it add sheets when I run the code with other versions of the "ft" data frame

enter image description here

1 Answer

you can use xlsx package for that. Could you try with below code ?

library(xlsx)
write.xlsx(dataframe1, file="filename.xlsx", sheetName="sheet1")
write.xlsx(dataframe2, file="filename.xlsx", sheetName="sheet2", append=TRUE)
8

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like