I have a data frame e.g.
a=1:10
b=31:40
c=data.frame(a=a,b=b)
and I will need to write this data frame into a specific Excel sheet ("Sheet1").
I am using WriteXLS now but this function always overrides the entire excel file and thus deletes other sheets. How can I append to the sheet without overwriting previous entries?
You can simply write into a new sheet of an existing Excel file without modifiying the existing sheets or any other information by doing it this way:
Remember to set the append argument of write.xlsx to TRUE and make sure the Excel file you are writing in to is in your current working Directory.
This will add a new named sheet to an existing Excel workbook without altering existing sheets:
Note that if the workbook already has a
Sheet1
then this function would silently overwrite it. So you'll need to make sure your sheet names are unique.Try with xlsx package. You have the function write.xlsx() which allows you to specify a name sheet and you can complete an existing excel.