# Add a second data set in a new worksheet
This is illustrated in the following R code : # Write the first data set in a new workbook To add multiple data sets in the same Excel workbook, you have to use the argument append = TRUE. Note that, the above code saves the Excel file in your current working directory. Write.xlsx(USArrests, file="myworkbook.xlsx", append : a logical value indicating if x should be appended to an existing file.col.names, row.names : a logical value specifying whether the column names/row names of x are to be written to the file.sheetName : a character string to use for the sheet name.x : a ame to be written into the workbook.This article is a quick start guide to manipulate Excel files in R using xlsx package. Unfortunately the xlsx package is not especially well documented. It works for both Excel 2007 and Excel 97/2000/XP/2003 file formats ( xls and xlsx file formats).
It is a java-based solution and it is available for Windows, Mac and Linux. Xlsx package is one of the powerful R packages to read, write and format Excel files. The different ways to connect R and Excel has been already discussed in our previous article. There are many solutions to import and export Excel files using R software.