Description Usage Arguments Details See Also Examples
A simple wrapper around write.xlsx
from the xlsx
package
1 2 |
x |
A |
file |
the path to the output file. This should include the '.xlsx' file extension |
sheetName |
a character string with the sheet name. |
col.names |
a logical value indicating if the column names of |
row.names |
a logical value indicating whether the row names of |
append |
a logical value indicating if |
showNA |
a logical value. If set to FALSE, NA values will be left as empty cells |
overwrite |
a logical value indicating if |
This function is a basic wrapper around write.xlsx
from the
xlsx
package designed to modify some of the default behaviour. The
main difference is the addition of the overwrite
argument. This is
intended to allow the user to overwrite sheets that already exist in the
workbook. If the Excel file specified by file
already exists and
includes a worksheet with same name as sheetName
then this sheet
will be deleted and replaced if overwrite=TRUE
. If
overwrite=FALSE
then the sheet is appended to the end of the file.
The default for append
in the underlying write.xlsx
function
is FALSE
. If the file you want to write to already exists you should
set this to append=TRUE
. If the file exists and append=FALSE
the existing file will be deleted and replaced. In most cases
append=TRUE
is probably what you want.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #basic usage for a new file
#creates a temporary file in the current directory
data(iris)
f = paste0('./temp','.xlsx')
saveXLSX(x = iris, file = f, sheetName = 'Test')
#using the same file as above
#use a different data set but keep the same name
#if the file already exists set overwrite = TRUE and append = TRUE
data(CO2)
saveXLSX(x = CO2, file = f, sheetName = 'Test', append = TRUE,
overwrite=TRUE)
#if overwrite = FALSE then the new sheet is appended at
#the end of the file
#use another different data set.
data(Indometh)
saveXLSX(x = Indometh, file = f, sheetName = 'Test', append = TRUE,
overwrite=FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.