3 R packages

“R packages are collections of functions and data sets developed by the community. They increase the power of R by improving existing base R functionalities, or by adding new ones.”1

Basically, R packages are nothing but collections of functions bundled together in a way that makes sense. Like different cookbooks that only contain recipes for a particular kind of food. They can be installed from many different sources which will be explored below.

3.1 From CRAN

The Comprehensive R Archive Network (CRAN) package repository features 18,000+ R packages. Here’s the list of Available CRAN Packages By Name. Most general purpose packages can be found here, however due to reasons, some packages are only available from other sources.

As a first example, we will download the tidyverse, a collection of R packages for data science.

“The tidyverse is an opinionated collection of R packages designed for data science. All packages share an underlying design philosophy, grammar, and data structures.”

We can install packages from CRAN with the install.packages() function like this:

install.packages("tidyverse")

Note, that we can also download more than one package at once using a vector (c()) containing all package names:

install.packages(c("BiocManager", "devtools"))

BiocManager as well as devtools will be used in the following to download R packages from other sources.

3.2 From Bioconductor

The Bioconductor is a collection of R packages for bioinformatics purposes. The first packages we will need from the Bioconductor will be downloaded with the install() function from the BiocManager package:

BiocManager::install(c("clusterProfiler",
                       "org.Hs.eg.db"
                       "UniProt.ws"))

3.3 From GitHub and others sources

Another important source of R packages is GitHub. GitHub is not just the place where most R packages are being developed before they are put to repositories such as CRAN or Bioconductor, many other packages including the pOmics packages can be installed from it as well. :)

Let’s do it with the install_github() function from devtools:

devtools::install_github("nicohuttmann/pOmics")

There are some other sources for R packages, which we want to use. Here, we are downloading the disgenet2r package to query the DisGeNET database for gene disease associations:

devtools::install_bitbucket("ibi_group/disgenet2r")