Conda: install R package from github [duplicate] - r

any one can suggest how to use conda in Linux to install R package from github?
Thanks!

According to this: https://github.com/conda/conda/issues/6674
You can create your own conda skeleton of a github derived R-package much as you would for a CRAN package.
Try doing
conda skeleton cran <github_url>
conda build --R=<my_r_version> r-<lower-case-package-name>
Then upload the built conda package to your own anaconda repository.
This will fail if any of the dependencies of the package are absent from the anaconda repos that you have access to. So you might have to conda-build a few other packages along the way.
Alternatively, you could install it directly with devtools::install_github(github_url, dependencies = FALSE). If you do go down this route, please ensure that any conda-available dependencies for the github package are already installed.
If you don't use dependencies = FALSE R will install.packages a bunch of updates. (As far as I can tell) When you install.packages a pre-installed package some_package in a conda env (eg, to update it) and then check conda list <some_package> on your current env, it will show the version that was installed by conda, rather than the updated version.
Edited build command, following #rpanai s suggestion

Related

Using conda to build and install local or custom R package

I would like to install a local R package into a conda environment. The package is not on CRAN or github (and not on any conda channel).
For packages on CRAN this is relatively straightforward:
conda skeleton cran <pckg>
conda-build r-<pckg>
conda install --use-local r-<pcgk>
For packages on github this works similarly: install R package from github using "conda" (apart from some issues of versions requiring tags).
conda skeleton cran <url>/<pcgk>
conda-build r-<pckg>
conda install --use-local r-<pcgk>
However, I cannot get this to work with a local package (the package builds without problems using R CMD build). This is what I have tried:
conda skeleton cran <path>/<pcgk>
Connects to cran and then (of course) does not find the package.
conda skeleton cran --cran-url <relative_path>/<pckg> <pckg>
throws an error with:
requests.exceptions.MissingSchema: Invalid URL '<relative_path>/<pckg>/src/contrib/': No schema supplied. Perhaps you meant http://<relative_path>/<pckg>/src/contrib/?
conda skeleton cran <absolute_path>/<pckg> <pckg>
Throws:
File "/home/myuser/.conda/envs/myenv/lib/python3.9/site-packages/conda_build/skeletons/cran.py", line 743, in package_to_inputs_dict
pkg_name = re.match(r'(.*)_(.*)', pkg_filename).group(1).lower()
AttributeError: 'NoneType' object has no attribute 'group'
And lastly:
conda skeleton cran --cran-url <absolute_path>/<pckg> <pckg>
Throws:
File "/home/myuser/.conda/envs/myenv/lib/python3.9/site-packages/requests/sessions.py", line 742, in get_adapter
raise InvalidSchema("No connection adapters were found for {!r}".format(url))
requests.exceptions.InvalidSchema: No connection adapters were found for '<absolute path>/<pckg>/src/contrib/'
Is this not possible with conda? Or am I making a mistake?
Here someone tried to write the skeleton files for a local package themselves, but it seems without success.
If you can upload your R package to your private github repository, then you could proceed with the common conda skeleton cran <github_pckg_http_or_ssh>.
conda will ask (internally by git, I think) for your password to retrieve the code.

build and install r package from github repository under Windows

I would like to build an R package from a github repository for an older version of R:
https://github.com/suiji/Arborist/
The R package is actually Rborist, so not sure whether to clone the whole repo mentioned above?
I installed Rtools after miserably failing to run:
library(devtools)
install_github("https://github.com/suiji/Arborist/tree/master/Rborist/src")
or:
library(devtools)
install_github("suiji/Arborist")
What do I have to do to build this package please?

install R package from github using "conda"

any one can suggest how to use conda in Linux to install R package from github?
Thanks!
According to this: https://github.com/conda/conda/issues/6674
You can create your own conda skeleton of a github derived R-package much as you would for a CRAN package.
Try doing
conda skeleton cran <github_url>
conda build --R=<my_r_version> r-<lower-case-package-name>
Then upload the built conda package to your own anaconda repository.
This will fail if any of the dependencies of the package are absent from the anaconda repos that you have access to. So you might have to conda-build a few other packages along the way.
Alternatively, you could install it directly with devtools::install_github(github_url, dependencies = FALSE). If you do go down this route, please ensure that any conda-available dependencies for the github package are already installed.
If you don't use dependencies = FALSE R will install.packages a bunch of updates. (As far as I can tell) When you install.packages a pre-installed package some_package in a conda env (eg, to update it) and then check conda list <some_package> on your current env, it will show the version that was installed by conda, rather than the updated version.
Edited build command, following #rpanai s suggestion

How to install GGRAPH package to the latest R (v.3.3.2)

I am very new to R and I need ggraph library and it can't be installed from rstudio console. Here is a message:
Warning in install.packages : package ‘ggraph’ is not available (for
R version 3.3.2)
Are there other ways of installation? Looks like this library lives and flourishes:
https://www.r-bloggers.com/introduction-to-ggraph-layouts/
This requiresudunits2 library.
I use conda R, so I installed it using conda install -c ioos udunits2=2.2.20. You need to use a package manager to get it installed.
Then install the udunits2 R package
install.packages('udunits2', type = "source",
configure.args=c('--with-udunits2-lib=/Users/Karthik/anaconda/lib'))
Replace /Users/Karthik/anaconda/lib with the path to your R libraries. You can find it using .libPaths()
Finally install the development version of R packages
devtools::install_github("thomasp85/ggraph", dependencies=TRUE)

Possible to install a package without installing dependencies?

Is it possible to install a package without installing dependencies?
When run the following command:
install.packages("package",dependencies=FALSE)
if the dependencies are not installed beforehand, isn't it that the installation of the package fails?
My question comes from this post Install a local R package with dependencies from CRAN mirror. Why does it say installing a local package without installing dependencies?
if I set repos=NULL it correctly tries to install the local package
file (as documented), but obviously it does not find the dependencies
packages.
Thanks!
You cannot install and get a package to work without its dependencies. The dependencies= parameter is really an indicator if you would like R to automatically install the dependencies. If set to FALSE, R still stop and warn you so you can decide what you would like to do; if TRUE, R will automatically try to download from your current CRAN repository mirror. With repos=NULL (a local file install) there is nowhere else to look for dependencies so the dependencies= parameter is ignored.

Resources