To install an R packages from GitHub from devtools package.
First, you need to install devtools by running the following code:
R
install.packages ( "devtools" ) |
Output
Once devtools is installed, you can use the install_github() function to install an R package from GitHub. The syntax is:
R
devtools:: install_github ( "github_username/github_repo" ) |
For example, to install the tidyverse package from GitHub, you would run:
R
devtools:: install_github ( "tidyverse/tidyverse" ) |
This will directly download and install the tidyverse package from GitHub.
It should be noted that certain packages may require the installation of extra dependencies before they can be utilised. In this instance, install_github() will attempt to install these dependencies as well. If you run into any problems during the installation, you may try manually installing any missing dependencies with the install.packages() function.
Choose the Right R Packages
The traditional way of discovering R packages is just by learning R, in many tutorials and courses the most popular packages are usually mentioned and used. The first alternative can be to browse categories of CRAN packages. CRAN is the official repository, also gives us the option to browse through packages.
Another alternative to finding packages can be R Documentation, a help documentation aggregator for R packages from CRAN, BioConductor, and GitHub, which offers you a search box ready for your requests directly on the main page.
Packages in R Programming
The package is an appropriate way to organize the work and share it with others. Typically, a package will include code (not only R code!), documentation for the package and the functions inside, some tests to check everything works as it should, and data sets.