Convert csv to excel without using xlsx package

I want to convert csv file to excel.

I found from a search on the Internet that the best suggestion is to use the library (xlsx) and use write.xlsx (..) to write my data file to an excel file.

However, when I try to download and use the xlsx library and use it, I get 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 csv to excel or is there anyone who has run into a previous problem?

+4
r
source share
2 answers

A minimal CRAN study shows several packages:

  • XLconnect requires Java
  • xlsx requires Java
  • openxlsx is NOT needed by Java, but it is younger and less widely used
  • writexls uses Perl under the hood, which is available on most systems.
+2
source share

You can do this in rio without having to use java dependencies. 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 want to do this directly with openxlsx, you can run something like:

 library("openxlsx") write.xlsx(read.csv("mtcars.csv"), "mtcars.xlsx") 

Full disclosure: I am the author of rio.

+4
source share

All Articles