How to Install Development Version of R Packages Github Repository

How to install development version of R packages github repository

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

How to specify lib directory when installing development version R Packages from github repository

To add specified library paths in devtools, we need to use with_libpaths()

Arguments for with_libpaths() are, with_libpaths(new, code)

Following is an example for using with_libpaths(),

library(devtools)
with_libpaths(new = "/usr/lib/R/site-library/", install_github('rCharts', 'ramnathv'))

Courtesy: Hadley, here :)

And other than with_libpaths(), there are more options for in devtools::with_something()

in_dir: working directory
with_collate: collation order
with_envvar: environmental variables
with_libpaths: library paths, replacing current libpaths
with_lib: library paths, prepending to current libpaths
with_locale: any locale setting
with_options: options
with_path: PATH environment variable
with_par: graphics parameters

More explanations here

How to install a development version of R package from google code and/or launchpad.net?

Using the devtools package, there is an install_url function which will automate the process of downloading the source code, building the package, and installing it.

install_url("http://igraph.googlecode.com/files/igraph_nightly_0.6-2689-20120412.tar.gz")

Versioning an R package with git/github?

I highly recommend to follow the Git Flow branching model, where:

  • the master branch contains code of the latest stable release. Use version format x.y.z
  • the develop branch contains code under development. Use version format x.y.z-9000

Let master be the default checkout branch on GitHub. That way users will always get the latest release, when they install R packages using:

install_github("owner/repos")

Users who wish to install the developers version, can use:

install_github("owner/repos@develop")

Next, if your package is also on CRAN, be strict and have master reflect exactly what is on CRAN. That way the user install the same identical package version regardless whether they use:

install.packages("repos")

or

install_github("owner/repos")

This way people also see the same info regardless of they visit your CRAN page or your GitHub page. Moreover, you can rest assured that all users will see the same stable information / version, even if you tag along updating the develop (only savvy users will be aware of this branch).

Next, when you release new versions, you can git tag them with their version number, e.g.

git checkout master
git tag 1.2.3
git push --tags

That way users can install whatever version they'd like, e.g.

install_github("owner/repos@1.2.3")

Tools for this? The git flow extension is an awesome tool to orchestrate the above, e.g.

git checkout develop
git flow release start 1.2.4
emacs DESCRIPTION ## Update version x.y.z-9000 -> x.y.z+1
R CMD build ...
R CMD check ...
git flow release finish 1.2.4
git checkout master
git push
git push --tags
git checkout develop
emacs DESCRIPTION ## Bump version to x.y.(z+1)-9000
git commit -am "Bump develop version [ci skip]"
git push

I've used the above on a daily basis for a good two years - I cannot imagine not using it.

Install a github package alongside a CRAN package with the same name?

You can use devtools::dev_mode() for this. From the man page:

When activated, dev_mode creates a new library for storing installed packages. This new library is automatically created when dev_mode is activated if it does not already exist. This allows you to test development packages in a sandbox, without interfering with the other packages you have installed.

Install R packages from github downloading master.zip

This answer is just a refined version of my comments. Essentially you can install packages using devtools by unzipping a local zipfile downloaded from github, and then running the install function


install("path/to/unzipped_pkg_zip_file")

The latest dev version of devtools contains an install_local utility function that makes it easy to work directly with local zip files.

Use GitHub Package R Actions

After some time, I have found a workaround that for now is good enough if you want to test for the development version(like I wanted). You should include an install_github command in the check.yaml file. Here's an example:

 - name: Install dependencies
run: |
install.packages(c("remotes","testthat"),dependencies=TRUE)
remotes::install_github("tidyverse/dplyr")
remotes::install_cran("covr")
shell: Rscript {0}

The above snippet fixed my issue because I wanted to depend on a future dplyr version. You can view the full yaml file here.



Related Topics



Leave a reply



Submit