14

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

Thanks!

blueskyddd
  • 431
  • 4
  • 12
  • 1
    Not sure you can with `conda`, can you not use R to install it, perhaps `Rscript -e "devtools::install_github(...)"`? – r2evans Aug 28 '18 at 15:54
  • 1
    I prefer using `conda` to install R packages because of multiple experiences in installing R packages, esp. those with many dependencies, where `conda install` did it successfully and was much faster, but `install.packages, biocLite` etc. produced errors and were very slow. – blueskyddd Aug 29 '18 at 16:08
  • I suggest that when you start installing packages from github, you are opening yourself up to countless dependency and version issues. You are intentionally installing a version that is either (a) known to be development and therefore not necessarily stable, or (b) not installed on CRAN, so the dependency and rev-dep trees cannot be verified or assured. Good luck, I think you're on your own. Possibly: https://github.com/conda/conda/issues/6674 and https://stackoverflow.com/questions/34705917/conda-how-to-install-r-packages-that-are-not-available-in-r-essentials – r2evans Aug 29 '18 at 16:16
  • Thanks @r2evans for the suggestions! The first link give some helpful info, but no clear answer. – blueskyddd Aug 30 '18 at 17:53
  • 1
    Another suggestion: this is less about *programming* (SO) as it is about tool administration, so you might find better luck at [superuser](https://superuser.com/). I don't know that it's nearly as active as SO in things like this, but it might be a better focus. Just a thought. – r2evans Aug 30 '18 at 19:04

1 Answers1

9

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

Russ Hyde
  • 2,154
  • 12
  • 21
  • 1
    Thanks for the info! What do you me by "upload the built conda package to your own anaconda repository"? – blueskyddd Sep 27 '18 at 14:20
  • Go to anaconda.org. Open an account. Then if you build a conda package, you have somewhere in the cloud where you can store it. And when you want to install it you can `conda install -c ` from whatever computer you are on. – Russ Hyde Sep 28 '18 at 11:07
  • 1
    It looks like the last command should be `conda build --R= r-` – rpanai Aug 12 '20 at 18:12