the below shows my attempt to install a package in R using install.packages from a tar.gz but I get an error which is rather unhelpful. Any ideas?
The 127 error message means that there is no C/C++ compiler accessible for the build process in install.packages().
In order to install R packages from source in the Windows operating system, one must first install the R Windows Tools. RTools for Windows may be downloaded from the CRAN RTools for Windows Download Page.
I am trying to use .xlsx library but function write.xlsx is returning error that such can not be found.
When I am installing library(xlsx) in log I can read:
Error : .onLoad nie powiodło się w funkcji 'loadNamespace()' dla pakietu 'rJava', szczegóły:
wywołanie: fun(libname, pkgname)
błąd: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
In addition: Warning messages:
1: pakiet ‘xlsx’ został zbudowany w wersji R 3.3.2
2: pakiet ‘rJava’ został zbudowany w wersji R 3.3.3
Error: pakiet ‘rJava’ nie mógł zostać załadowany
Java is up to date.
The code in the original post fails because the xlsx package uses the Apache POI Java API to Excel, and therefore requires the rJava package. In turn, the rJava package requires a working, compatible version the Java Runtime Environment to be installed on the machine and accessible from R.
One can tell whether Java is accessible from R / RStudio via the system() function.
> system("java -version")
java version "13.0.2" 2020-01-14
Java(TM) SE Runtime Environment (build 13.0.2+8)
Java HotSpot(TM) 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing)
>
There are at least four sets of R packages used for working with Excel files, including:
xlsx -- requires rJava package
XLConnect -- requires rJava package
openxlsx -- does not require rJava package
readxl / writexl -- does not require rJava package
For options 3 and 4, the solution is simply to use install.packages() to install the desired package (as noted in another answer by #Linus), once you've updated R to the latest version.
install.packages("openxlsx")
library(openxlsx)
or
install.packages(c("readxl","writexl"))
library(readxl)
library(writexl)
A Working Example: Write to Excel File
library(writexl)
data <- data.frame(matrix(runif(100),nrow=10,ncol=10))
write_xlsx(data,"./data/simpleExcel.xlsx")
...and the output:
If You Must Use rJava...
Unfortunately, options 1 and 2 are considerably more complicated than "install Java." If one must use xlsx or needs the rJava package to support other R packages, installation of Java varies significantly by operating system.
Windows: one must install a version of Java whose architecture is compatible with R (i.e. 32-bit vs. 64-bit). One may consider installing both 32-bit and 64-bit versions because some Windows programs installed on the computer may require 32-bit Java vs. 64-bit. With RStudio, one can configure R to use the 32-bit version of R if only 32-bit Java is installed on the machine.
Mac OS X: one must install Java and run a series of commands that are documented on the rJava Issues GitHub page, including executing an R script to reconfigure Java for R.
Linux: one needs to install Java using the package installer tool appropriate for the version of Linux, and then configure R to use it. For example, in Ubuntu one would install with the advanced packaging tool.
sudo apt-get install openjdk-8-jdk # openjdk-9-jdk has some installation issues
sudo R CMD javareconf
xlsx needs Java. Please install the current Java version from https://www.java.com/de/
and watch out, that both R and java are either 32bit or 64bit as it is stated in the error message
... and make sure R and Java have matching architectures.
Or use writexls or openxlsx. They are not depending on Java (Thanks #Len)
This the the error I get when I try to install or update any packages within Rstudio (latest version) on Windows 8 x64:
"Error in install.packages : object 'Rmd5' not found."
Try running the install or update in straight old R 64 bit version.
If you can make that fly. I would install installR using R 64 bit (NOT STUDIO) you can then use that to update any and all packages and versions of R pretty effortlessly. It manages dependencies and errors well.
I tried to install rPython under windows with install.packages("rPython"). However I am getting an error that the package does not exist.
Warning in install.packages :
package ‘rPython’ is not available (for R version 3.2.5)
In the installation doc of the package I can only find this:
WINDOWS SYSTEMS
===============
On a Windows system, the package can only be installed from source at this time. Details to come.
Is there a work-around to work with Python in R?
Try 'rPython-win' if you use windows.
rPython works in Linux.
https://github.com/cjgb/rPython-win
So I recently (1 hour ago) updated to a 64-bit version of R and tried installing some of my trusty packages in the fresh install (Windows seperates 64/32 bit programs now in two program folders).
Is there a work around for this?
Warning message:
In getDependencies(pkgs, dependencies, available, lib) : package ‘RMySQL’ is not available
Got it sorted. Download and install manually:
install.packages("C:\\Path\\to\\file\\windows_binary.zip",repos=NULL)
Happy Friday!