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?
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.
A minimum of research on CRAN reveals a number of packages:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With