I calculated a series of data in R and would like to know which command I should use to move them to an excel spreadsheet.
I calculated a series of data in R and would like to know which command I should use to move them to an excel spreadsheet.
The command to be run using the package xlsReadWrite should be:
library(xlsReadWrite)
write.xls(mydata, "c:/arquivo.xls")
Or you can use one of the following packages:
The WriteXLS package may be useful. After installing the package, just type the following command:
WriteXLS("m", "n.xls")
Where m
is the database you are working in Excel and n
the name of the article you want to export in xls.
With this package, you can edit some features of the exported file, such as the headers and width of the columns ...
You can use:
library(xlsx)
write.xlsx(nomeObjeto,file="nomeObjeto.xlsx")
Even using Excel I prefer to work with CSV files (text always!), which with proper formatting, open in Excel with no problems.
To create the CSV files I like to use write.table
.
For the files to be opened in Excel in Portuguese correctly I use:
write.table(df, file='arquivo.csv', sep=';', dec=',', row.names=FALSE)
In order for files to be opened in Excel in English correctly I use:
write.table(df, file='arquivo.csv', sep=',', dec='.', row.names=FALSE)
You can directly open the file in Excel by clicking on the file icon (at least Windows). With the advantage that the file is portable to any other program and OS.