To easily export a dataframe to XML format you can use the write.xml function of the kulife package, indicating as first argument the dataset and the name of the exported file in the second. On the other hand, the writexl library provides the write_xlsx function to export data frames in R to Excel: # install.packages("writexl") On the one hand, the write.xlsx function of the openxlsx allows you to write a data frame or list of data frames to an XLSX file: # install.packages("openxlsx") However, the main disadvantage of the previous package is that requires JAVA installed on your computer, so if the JAVA_HOME is not specified or if R doesn’t find the rJava.dll file, the package won’t work.Īlternatives to export R output to XLSX that don’t require JAVA are the openxlsx and writexl packages: Row.names = TRUE, append = FALSE, showNA = TRUE, password = NULL)Īs an example, if you want to save the cars dataset you can type: write.xlsx(cars, "cars.xlsx") Write.xlsx2(x, file, sheetName = "Sheet1", col.names = TRUE, # Semi-colon as separator and comma as decimal separator ShowNA = TRUE, # If TRUE, NA are empty cells Row.names = TRUE, # Whether to include row names or notĪppend = FALSE, # Whether to append to an existing file SheetName = "Sheet1", # Name of the sheetĬol.names = TRUE, # Whether to include column names or not Write.xlsx(x, # Data frame to be exported # Comma as separator and dot as decimal separator The most known package to export data frames or tables as Excel is xlsx, that provides the write.xlsx and write.xlsx2 functions. Export data from R to Excel (XLS and XLSX)Įxporting data from R to Excel can be achieved with several packages.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |