How to Specify Lib Directory When Installing Development Version R Packages from Github Repository

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 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

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.

how do you install R packages from a private git repo with a PAT?

My go to :

gitcred <- git2r::cred_user_pass(username="$(USERNAME)",password="$(PAT)")
#here you can put any private repo such as devops azure or bitbucket, etc..
remotes::install_git("https://dev.azure.com/XXX", credentials = gitcred)'


Related Topics



Leave a reply



Submit