✍🏻 Installing R Packages from GitHubAugust 26, 2019
- R Studio
- GitHub and a Personal Access Token
Private Repository prerequisites
Note: If you wish to install from a private repo you need a token from your GitHub Settings. Otherwise feel free to skip this section.
GITHUB_PAT environement variable
Note: Don't commit your tokens!
or in your
Note: You will need to sign-in and start a new R session for the environment variable (accessed by Sys.getenv) to be visible.
Baked into the R devtools package there lives a function to install R packages hosted on GitHub.
install.packages("devtools") # Install latest devtools from CRAN library(devtools) # Load/Import devtools into working session
Install a package
This exposes the
install_github() function for use. Listed below are the arguments we are interested in populating.
repo # Repository address format username/package ref # Commit, tag, or branch name. Default value is Master auth_token # User personal access token
Our Final Command should look like this
Note: There are handlers for all flavors of version control.
install_github() from GitHub install_gitlab() from GitLab install_bitbucket() from Bitbucket install_url() from an arbitrary url install_git() and install_svn() from an arbitrary git or SVN repository install_local() from a local file on disk install_version() from a specific version on CRAN
Update a package
update_packages() updates a package to the latest version.
This works both on packages installed from CRAN as well as those installed from any of the functions listed above.
ref parameter to the function with the specific branch name in which you want to develop.
This can be a branch, tag, or commit.
install_github(repo="username/package", ref="develop", auth_token=Sys.getenv("GITHUB_PAT"))
Distributing a package build privately
- RStudio Shared Directory: Save the R package source code in a
Users can install these packages by navigation to the toolbar menu and executing.
- Option 1:
Tools > Install Packages > Select Build from picklist
- Option 2:
use the install.packages('<path>') function from the command line.
- Option 1: