65

How can I install a package that is under development directly from a github repository and once installed how can I switch between development and CRAN versions?

The specific package I am interested in installing from git is ggplot2.

Etienne Low-Décarie
  • 13,063
  • 17
  • 65
  • 87
  • 2
    Possible related thread: [How to manage multiple package locations (folders) in R?](http://stackoverflow.com/q/7993061/420055) – chl Mar 11 '12 at 20:54
  • Related: [Installing non-public packages from Gitlab using devtools::install_git](https://stackoverflow.com/q/27319207/562769) – Martin Thoma Sep 03 '17 at 14:15

4 Answers4

86

via Hadley at https://github.com/hadley/ggplot2

install.packages("devtools")

library(devtools)

dev_mode(on=T)

install_github("hadley/ggplot2")

# use dev ggplot2 now

# when finished do:

dev_mode(on=F)  #and you are back to having stable ggplot2
MichaelChirico
  • 33,841
  • 14
  • 113
  • 198
Seth
  • 4,745
  • 23
  • 27
  • 2
    The point of the question not only about how to install from Github (which is pretty clear) but also about how to switch between dev and release versions. Presumably without reinstalling... – Dirk Eddelbuettel Mar 11 '12 at 17:17
  • I just noticed that he wants to install and uninstall. Thanks for pointing that out. I am not sure the best way to do that but I edited above to show what I do. – Seth Mar 11 '12 at 23:15
  • 3
    PS: install_github requires the "make" command line tool which is installed on OS X by installing Xcode. – Etienne Low-Décarie Apr 23 '12 at 13:57
  • 1
    it changed a bit: `remotes::install_github("tidyverse/ggplot2")` – TobiO Oct 02 '19 at 08:18
19

I have the feeling that both previous answers miss the point of your question.

Consider this:

  • You can control where to install packages via arguments to both R CMD INSTALL (via -l) and install.packages().

  • At run-time, you can control where to load packages from via .libPaths().

So it really is just a matter of setting a few variables in your .Rprofile (or alike) to control this.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
3

for compile binaries install:

install.packages('xxx', repo='http://repo_adress')

for source install :

install.packages('xxx', repo='http://repo_adress', type='source')
Enrique Pérez Herrero
  • 3,699
  • 2
  • 32
  • 33
b_rousseau
  • 159
  • 8
1
devtools::install_github("ggplot2")
ferrelwill
  • 771
  • 2
  • 8
  • 20