How to install H2O R package on an offline server? - r

I had to install H2O R package on an offline server. I created a local repo via miniCRAN and tried to install the package from it but installation failed with this error:
Error in download.file(md5_url, destfile = md5_file, mode = "w", cacheOK = FALSE, :
cannot open URL 'http://s3.amazonaws.com/h2o-release/h2o/rel-vajda/3/Rjar/h2o.jar.md5'
Error : unable to load R code in package ‘h2o’
ERROR: lazy loading failed for package ‘h2o’
* removing ‘/usr/lib64/R/library/h2o’
I circumvented this by manual transferring of installed binaries from an online server but this is obviously just a workaround. So is there a normal way to install H2O R package on an offline server?

The R install package is embedded in the zip download file.
This will work, assuming all the dependencies have also been downloaded and installed.
(Of course, substitute the specific version that you want.)
wget https://h2o-release.s3.amazonaws.com/h2o/rel-weierstrass/2/h2o-3.14.0.2.zip
unzip h2o-3.14.0.2.zip
cd h2o-3.14.0.2
cd R
R CMD INSTALL h2o_3.14.0.2.tar.gz

You have to have h2o.jar already downloaded.
Then set environment variable like so:
Sys.setenv(H2O_JAR_PATH="_your_h2o_installation_path_/h2o.jar").

This worked for me.
First download the h2o package archive and get the Jar file then set up H2O_JAR_PATH using this command
Sys.setenv(H2O_JAR_PATH="/home/hadoop/R/h2o.jar")
Finally,
install.packages("~/R/h2o_3.20.0.8.tar.gz", repos = NULL, type = "source")
library(h2o)

Related

installing package from zip file with no tar.gz [duplicate]

I have download this package as a zip file.
Is it possible to install it from R console using this zip or unzip version to a specific path?
install.packages("C:/Users/Desktop/rvest-master.zip', lib='C:/R/R-3.2.1',repos = NULL)
I type the previous command but is not working
> setwd("C:/Users/Desktop/")
> unzip("rvest-master.zip")
> file.rename("rvest-master", "rvest")
[1] TRUE
> shell("R CMD build rvest")
Warning messages:
1: running command ' /c R CMD build rvest' had status 127
2: In shell("R CMD build rvest") :
'R CMD build rvest' execution failed with error code 127
> install.packages("rvest_0.2.0.9000.tar.gz", repos = NULL)
Installing package into ‘C:/Users/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning: invalid package 'rvest_0.2.0.9000.tar.gz'
Error: ERROR: no packages specified
Warning messages:
1: running command '"C:/R/R-3.2.1/bin/x64/R" CMD INSTALL -l "C:\Users\Documents\R\win-library\3.2" "rvest_0.2.0.9000.tar.gz"' had status 1
2: In install.packages("rvest_0.2.0.9000.tar.gz", repos = NULL) :
installation of package ‘rvest_0.2.0.9000.tar.gz’ had non-zero exit status
In the previous line are the results from the answer
You have downloaded a zip of the source of a package. This is not the standard packaging of a package source nor is it a standard Windows binary (i.e., a built package distributed as a .zip, as from CRAN).
The easiest thing for you to do is to install this package directly from Github using devtools:
library("devtools")
install_github("hadley/rvest")
If you decide to install it locally, you need to unzip the package directory, build it from the command line using R CMD build rvest and then install either using R CMD INSTALL or from within R using the command you already have (but performed on the built "tarball"). Here's how you could do all of this from within R:
setwd("C:/Users/Desktop/")
unzip("rvest-master.zip")
file.rename("rvest-master", "rvest")
shell("R CMD build rvest")
This will make a tarball version of the package in the current directory. You can then install that with
install.packages("rvest_0.2.0.9000.tar.gz", repos = NULL)
Since the version number is merged into the tarball name, it may not always be obvious what the new file might be called. You can use list.files() to grab the new tarball.
install.packages(list.files(pattern="rvest*.tar.gz"), repos = NULL)
If the shell() line gives you an error like this
'R' is not recognized as an internal or external command
You need to make sure that R is in your shell path. You can add it with something like
Sys.setenv(PATH=paste(R.home("bin"), Sys.getenv("PATH"), sep=";"))
Try install.packages('C:/Users/Desktop/rvest-master.zip', repos = NULL, type = "win.binary"). (Untested)
Hard to believe this don't have a clear, simple and accurate answer.
The zip you downloaded from github by clicking "download as zip" is a pack of that repo, which is not the standard R source package format like CRAN hosted. Thus the methods that work with CRAN source tar.gz will not work with this kind of zip.
The simplest method is to use devtools::install_local. If devtools bring too many dependencies to you, you can use remotes::install_local which is the real function and have much less dependencies.
If this is the zip of the source of a package, and the R core install.packages() doesn't work, then you can use install_local() from the devtools package.
I often do this when installing packages from GitHub as getting curl through our proxy is painful. So I download the source zip and install like this.
On Windows 7 and R 3.5.3 I had to extract the zip, repackage it as .tar.gz and then install it using the command below. When installing the zip the package will not be indexed by R.
install.packages("C:/your-package.tar.gz", repos = NULL, type = "win.binary", lib="C:/Users/username/Documents/R/R-3.5.3/library")
Environment
version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 5.3
year 2019
month 03
day 11
svn rev 76217
language R
version.string R version 3.5.3 (2019-03-11)
nickname Great Truth
You can make use of install_local method in devtools package. Unzip the zipped file and specify the folder which contains DESCRIPTION file of the package in the path argument or you can also make use of subdir argument.
If it doesn't explains, I will post an example... Let me know.
Download the package.tar.gz
Then from command line :
R CMD INSTALL package.tar.gz

Loading dependencies from package-internal packrat library

I am building an R package with packrat. The package is fully tested and installation from the locally saved source file by
install.packages("myPackage.tar.gz", repos = NULL, type = "source")
works if all dependencies (specified in the Imports: field) are installed on the local machine.
However, I would like to install that package on another server where dependencies are not installed. When I try to do this, I get the error
"ERROR: dependencies ‘survey’, ‘dplyr’ are not available for package 'myPackage'"
I also tried to install the packrat bundle which I created by calling
packrat::bundle(project = 'pathtomypackageproject', file = 'myPackage.tar.gz',
include.lib = TRUE)
but I get the same error.
I think the problem is that, upon installing 'myPackage', R searches the first element of .libPaths(), doesn't find anything and since "repos = NULL" is specified, has nowhere to install the packages from so the error is thrown.
A solution I'm still trying to avoid is to transfer a repository containing all dependencies to the server and pointing to the repository when installing the package. Ideally, I only have to transfer myPackage.tar.gz.
My question is if there is some way to point to the internal packrat library, where all dependencies can be found, and import the namespaces from there.
If you have included the list of packages to be imported in DESCRIPTION File, then you just need to do this while installation of your package:
install.packages("myPackage",dependencies=TRUE)

unable to install R library in azure ml

I have been trying to install a machine learning package that I can use in my R script.
I have done placed the tarball of the installer inside a zip file and am doing
install.packages("src/packagename_2.0-3.tar.gz", repos = NULL, type="source")
from within the R script. However, the progress indicator just circles indefinitely, and it's not installed in environment.
How can I install this package?
ada is the package I'm trying to install and ada_2.0-3.tar.gz is the file I'm using.
You cannot use the tarball packages. If you are on windows you need to do the following:
Once you install a package (+ it's dependencies) it will download the packages in a directory
C:\Users\xxxxx\AppData\Local\Temp\some directory
name\downloaded_packages
These will be in a zip format. These are the packages you need.
Or download the windows binaries from cran.
Next you need to put all the needed packages in one total zip-file and upload this to AzureML as a new dataset.
in AzureML load the data package connected to a r-script
install.packages("src/ada.zip", lib = ".", repos = NULL, verbose = TRUE)
library(ada, lib.loc=".", verbose=TRUE)
Be sure to check that all dependent packages are available in Azure. Rpart is available.
For a complete overview, look at this msdn blog explaining it a bit better with some visuals.

How to install a package from a download zip file

I have download this package as a zip file.
Is it possible to install it from R console using this zip or unzip version to a specific path?
install.packages("C:/Users/Desktop/rvest-master.zip', lib='C:/R/R-3.2.1',repos = NULL)
I type the previous command but is not working
> setwd("C:/Users/Desktop/")
> unzip("rvest-master.zip")
> file.rename("rvest-master", "rvest")
[1] TRUE
> shell("R CMD build rvest")
Warning messages:
1: running command ' /c R CMD build rvest' had status 127
2: In shell("R CMD build rvest") :
'R CMD build rvest' execution failed with error code 127
> install.packages("rvest_0.2.0.9000.tar.gz", repos = NULL)
Installing package into ‘C:/Users/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning: invalid package 'rvest_0.2.0.9000.tar.gz'
Error: ERROR: no packages specified
Warning messages:
1: running command '"C:/R/R-3.2.1/bin/x64/R" CMD INSTALL -l "C:\Users\Documents\R\win-library\3.2" "rvest_0.2.0.9000.tar.gz"' had status 1
2: In install.packages("rvest_0.2.0.9000.tar.gz", repos = NULL) :
installation of package ‘rvest_0.2.0.9000.tar.gz’ had non-zero exit status
In the previous line are the results from the answer
You have downloaded a zip of the source of a package. This is not the standard packaging of a package source nor is it a standard Windows binary (i.e., a built package distributed as a .zip, as from CRAN).
The easiest thing for you to do is to install this package directly from Github using devtools:
library("devtools")
install_github("hadley/rvest")
If you decide to install it locally, you need to unzip the package directory, build it from the command line using R CMD build rvest and then install either using R CMD INSTALL or from within R using the command you already have (but performed on the built "tarball"). Here's how you could do all of this from within R:
setwd("C:/Users/Desktop/")
unzip("rvest-master.zip")
file.rename("rvest-master", "rvest")
shell("R CMD build rvest")
This will make a tarball version of the package in the current directory. You can then install that with
install.packages("rvest_0.2.0.9000.tar.gz", repos = NULL)
Since the version number is merged into the tarball name, it may not always be obvious what the new file might be called. You can use list.files() to grab the new tarball.
install.packages(list.files(pattern="rvest*.tar.gz"), repos = NULL)
If the shell() line gives you an error like this
'R' is not recognized as an internal or external command
You need to make sure that R is in your shell path. You can add it with something like
Sys.setenv(PATH=paste(R.home("bin"), Sys.getenv("PATH"), sep=";"))
Try install.packages('C:/Users/Desktop/rvest-master.zip', repos = NULL, type = "win.binary"). (Untested)
Hard to believe this don't have a clear, simple and accurate answer.
The zip you downloaded from github by clicking "download as zip" is a pack of that repo, which is not the standard R source package format like CRAN hosted. Thus the methods that work with CRAN source tar.gz will not work with this kind of zip.
The simplest method is to use devtools::install_local. If devtools bring too many dependencies to you, you can use remotes::install_local which is the real function and have much less dependencies.
If this is the zip of the source of a package, and the R core install.packages() doesn't work, then you can use install_local() from the devtools package.
I often do this when installing packages from GitHub as getting curl through our proxy is painful. So I download the source zip and install like this.
On Windows 7 and R 3.5.3 I had to extract the zip, repackage it as .tar.gz and then install it using the command below. When installing the zip the package will not be indexed by R.
install.packages("C:/your-package.tar.gz", repos = NULL, type = "win.binary", lib="C:/Users/username/Documents/R/R-3.5.3/library")
Environment
version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 3
minor 5.3
year 2019
month 03
day 11
svn rev 76217
language R
version.string R version 3.5.3 (2019-03-11)
nickname Great Truth
You can make use of install_local method in devtools package. Unzip the zipped file and specify the folder which contains DESCRIPTION file of the package in the path argument or you can also make use of subdir argument.
If it doesn't explains, I will post an example... Let me know.
Download the package.tar.gz
Then from command line :
R CMD INSTALL package.tar.gz

ActiveMQ package for R

I'm trying to have a model I've built in R sent messages to an activeMQ queue. A quick googling of R points me to Rjms; however, when I check for the package on CRAN, I get an error saying "Package ‘Rjms’ was removed from the CRAN repository." Further googling just pushes me back to Rjms.
Given this, is there an ActiveMQ package available in the R language?
You can install the current version from Github. First, you need to install the dependency Rjmsjars.
library(devtools)
install_github("cran/Rjmsjars")
install_github("smschauhan/Rjms/src/main/resources/Rjms")
I ended up installing the packages via wget tarballs rather than via github, as I was encountering a Java exception when loading the packages installed via github.
from the command line:
wget http://cran.r-project.org/src/contrib/Archive/Rjmsjars/Rjmsjars_0.0.1.tar.gz
wget http://cran.r-project.org/src/contrib/Archive/Rjms/Rjms_0.0.5.tar.gz
then within the R interactive terminal:
install.packages('~/Rjmsjars_0.0.1.tar.gz', repos = NULL, type ="source")
install.packages('~/Rjms_0.0.5.tar.gz', repos = NULL, type ="source")
When loading the package, I am indeed able to initialize a logger and send a message without a Java exception:
library(Rjms)
logger <- initialize.logger('tcp://xxx.xx:61616', 'Q', "test")
send.status<-to.logger(logger, "{xxx: xxx, xxx: .xx}")
send.status
[1] TRUE

Resources