ActiveMQ package for R - 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

Related

Errors downloading R package for "Efficient R Programming" by Gillespie and Lovelace

the above-referenced book has an associated R package hosted on github containing datasets and functions used in the book.
The book states this code is used to install the package:
devtools::install_github("csgillespie/efficient", build_vignettes = TRUE, dependencies = TRUE)
I receive the following message and errors when running the code:
SUMMARY: processing the following file failed:
'solutions07.Rmd'
Error: Vignette re-building failed.
Execution halted Error: Failed to install 'efficient' from GitHub:
System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed
Do you have any insight into whether the package itself is causing the error versus a local issue on my end? Or how I might figure out the cause and fix for this issue? I appreciate any help you can provide.
This URL provides the section in the online book I am referring to.
https://csgillespie.github.io/efficientR/introduction.html#book-resources
If I run the following code it works:
devtools::install_github("csgillespie/efficient", build_vignettes = TRUE, dependencies = TRUE)
devtools::install_github("csgillespie/efficientR")
I would suggest to reinstall the devtools package using the following code:
remove.packages("devtools")
install.packages("devtools", dependencies = TRUE)
library(devtools)
Was having the same problem. But after installing Rtools for windows: https://cran.rstudio.com/bin/windows/Rtools/rtools42/rtools.html
And installing from source packages that were recommended to update:
recommended packages
Was able to succefully use efficient, and access its vignettes.
Using version R-4.2.1
devtools version 2.4.5

Error in git checks when running devtools::release() in preparation for releasing package in R

I am trying to release a package to CRAN using devtools::release(). Whenever I get to the step for Running Git checks... I get an error.
── Running Git checks for fitzRoy ───────────────────────────────────────────────────────────────────────
Current branch: master
Checking uncommitted files... OK
Checking synchronisation with remote branch...
ERROR: Error in 'git2r_remote_fetch': unsupported URL protocol
I'm on a Mac. I've been using Git fine for the package and have no dramas committing, pushing and pulling.
I've tried updating devtools, git2r and also installing the latest version of Git but haven't had any luck.
Any suggestions?
Update - found an answer here.
Basically - you need to install libssh2. On a Mac I followed the instructions here.
I then had to re-install git2r package for R by running the following
install.packages("git2r", type = "source")
After doing that and restarting R, the error went away.

Install dependencies of custom package

I have developed a local package that depends on others available on CRAN (as an example, pool). Therefore, when I attempt to install the package using the standard
install.packages("/path/to/package",
repos = NULL,
type = "source")
I get an error because the dependencies aren't installed. install.packages has an argument dependencies which by default would try to install those dependencies. However, as stated by the man page (and commented in the linked question below), repos = NULL means the dependencies are ignored.
To get around that, I used package miniCRAN to create a repo containing my package, hoping I could do a repos = c("myRepo", getOption("repos")) to get it to work.
Now I can install my package using
install.packages("package",
repos = c("/path/to/repo", getOptions("repos"),
type = "source")
But only if I've already installed pool. If not, I still get an error because it can't find the dependencies.
So I called miniCRAN::addPackage("pool"), which adds that package and its many dependencies to my repo, and they all appear if I call miniCRAN::pkgAvail().
However, if I attempt to install my package again, I still get a there is no package called 'pool' error.
Interestingly, if I try to install pool itself from the repo, it works.
install.packages("pool",
repos = "/path/to/repo",
type = "source")
install.packages("package",
repos = "/path/to/repo",
type = "source")
Obviously, however, this kind of beats the point of adding pool to the repo: I might just as well have installed it from CRAN.
So what's going on here, and is this really the only way to install local packages and their CRAN dependencies?
Figured it out.
The problem was a misunderstanding on my part regarding roxygen, which I've been using for my documentation. I assumed it handled the Imports: section of the DESCRIPTION file, which it doesn't ((1), (2)). So while the NAMESPACE file has all the necessary importFrom(pool, ...) calls, pool wasn't actually on my DESCRIPTION.
After fixing that oversight, using remote::install_local("path/to/pkg") (or devtools::install()) ((3)) worked: it installed my package and pulled its dependencies from CRAN.

How to install H2O R package on an offline server?

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)

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)

Resources