append output to xlsx or csv

I am trying to create a common workbook of output summaries. so I am trying to create a xlsx or csv file where i can append different sheets of output .

I have tried many options but nothing is working, after updating packages xlsx and rjava still write.xlsx not working.

writeData(wb, sheet=domain_ct, domain_ct)
Error in writeData(wb, sheet = domain_ct, domain_ct) : 
  could not find function "writeData"

> write.table(domain_ct,"C:/shoaib/ER/Uploader/Output_file.csv",append=T,sep=",")
Warning message:
In write.table(domain_ct, "C:/shoaib/ER/Uploader/Output_file.csv",  :
  appending column names to file

rite.xlsx(domain_ct, file = "Out_file.xlsx", sheetName="domain_ct", append=TRUE)
Error in write.xlsx(domain_ct, file = "Out_file.xlsx", sheetName = "domain_ct",  : 
  could not find function "write.xlsx"

I have a csv file named Dummy.csv with three columns named X1, X2, X3. The following code works to append data to it.

NewData <- data.frame(X1 = 1:3, X2 = 2:4, X3 = 3:5)
write.table(NewData, file = "Dummy.csv", append = TRUE, sep = ",", 
            col.names = FALSE, row.names = FALSE)

No, I want to append sheets for different outputs

CSV files do not have a structure that supports multiple sheets. If you want the stored file to have different sheets for different data, you cannot write to a CSV file.

I do not have the xlsx package, so I can be of limited help with that. Your attempt to use write.xlsx returned an error that said the function was not found. Hare you run the command


Do you want to append data to existing sheets or do you want to make a new sheet for each data set? I am not sure which of those options is done by the append argument. I read the documentation but it is not clear to me.

If you create a list from all the output then you can use write_xlsx (writexl package) to write each output to its own sheet.


my_output_list <- list("domain_ct"  = domain_ct, 
                       "domain_ct2" = domain_ct)

my_outfile <- "output.xlsx"
writexl(my_output_list, my_outfile)

its working thanks, after changing few things in my code

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.