How do I append data from a data frame in R to an Excel sheet that already exists
<p>I have created dozens of data frames in R and would like to append them all to one sheet in an Excel file. </p>

<p>Here are two of the pages I have looked at in an attempt to find an answer (I don't have 10 reputations so I can't paste all four webpage urls I have visited):</p>

<p><a href="http://www.r-bloggers.com/write-data-frame-to-excel-file-using-r-package-xlsx/" rel="noreferrer">Write data to Excel file using R package xlsx</a>
The author says: "You can also add the dataframes to a particular starting place in the sheet using the startRow and startCol arguments to the addDataFrame function."
Here is the suggested code: </p>

<pre><code>workbook.sheets workbook.test addDataFrame(x = sample.dataframe, sheet = workbook.test,
   row.names = FALSE, startColumn = 4) # write data to sheet starting on line 1, column 4
saveWorkbook(workbook.sheets, "test.excelfile.xlsx") # and of course you need to save it.
</code></pre>

<p>Based on this suggestion, this was my attempt in RStudio:</p>

<pre><code>addDataFrame(df_fl1, sheet = "AllData2.xlsx", startRow = 712)
</code></pre>

<p>This was R's output:
Error in sheet$getWorkbook : $ operator is invalid for atomic vectors</p>

<p>I've also tried this page:</p>

<p><a href="http://blog.datacamp.com/r-tutorial-read-excel-into-r/" rel="noreferrer">Tutorial on Reading and Importing Excel Files into R</a>
"If, however, you want to write the data frame to a file that already exists, you can execute the following command:"</p>

<pre><code>write.xlsx(df, 
           "&lt;name and extension of your existing file&gt;", 
           sheetName="Data Frame"
           append=TRUE)
write.xlsx(df_fl3, "AllData2.xlsx", sheetName="Salinity1", append=TRUE)
</code></pre>

<p>I tried this code and it overwrote the data that was already in the sheet. How can I append data from the data frames into an Excel sheet?</p>