Reputation: 141
I want to convert a csv file to excel.
I found from the search in Internet that the best proposal it to use the library(xlsx) and use the write.xlsx(..) to write my dataframe to excel file.
However when I try to load and use the xlsx library and use it I receive the following:
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/Ban/Documents/R/win-library/3.1/rJava/libs/x64/rJava.dll':
LoadLibrary failure: Could not find the specified mode. unit.
Is there any other way to convert the csv to excel or is there anyone faced the previous problem?
Upvotes: 5
Views: 7108
Reputation: 44585
You can do this in rio without needing a java dependency. It calls the openxlsx package.
install_github("leeper/rio")
library("rio")
# create an example CSV
export(mtcars, "mtcars.csv")
# convert the CSV to Excel (.xlsx)
convert("mtcars.csv", "mtcars.xlsx")
If you wanted to do this directly with openxlsx, you can run something like:
library("openxlsx")
write.xlsx(read.csv("mtcars.csv"), "mtcars.xlsx")
Full disclosure: I'm the author of rio.
Upvotes: 7
Reputation: 368647
A minimum of research on CRAN reveals a number of packages:
Upvotes: 3