Skip to content
Prev 200462 / 398503 Next

Writing a data frame in an excel file

anna_l wrote:
Base R cannot write .xls files by it's self.  You should output CSV using
write.csv():

  write.csv( dataFrame, file = 'results.csv' )

If you are using R on windows, then the RODBC package provides a mechanism
for dumping data frames directly to Excel files, possibly with multiple
sheets:

  require( RODBC )

  xlsFile <- odbcConnectExcel( 'results.xls', readOnly = F )

  sqlSave( xlsFile, dataFrame, tablename = 'R Results', rownames = F )

  odbcCloseAll()


The tablename argument to sqlSave allows you to assign a name to the excel
sheet that will contain the data.frame.


-Charlie

-----
Charlie Sharpsteen
Undergraduate
Environmental Resources Engineering
Humboldt State University