i

R Programming Complete Tutorial

Working with R Packages

Now is the time to start with R packages. We will know about the important packages for our work and install them in our environment.

What is an R package?

An R package is a suitable way to organize our work, and if we want to, share it with others. R packages are collections of R functions, data, and compiled code in a well-defined format.

There is a chance that someone has already solved a problem that we are working on, by using the R package, we can benefit from their work, just by downloading their packages. The concept is to use someone's solved (sharable) problem in our problem. This is the concept behind the creation of new packages.

Package Repositories:

A repository is a place where packages are located, from where we can install them. Although we may have a local repository, typically, R package repositories are online and accessible to everyone. We are going to mention only popular repositories for R below:

CRAN: This is the official repository for R packages. It is managed by the R Foundation, and for a package to be released, it needs to pass multiple checks ensuring that the package meets CRAN policies. It is a network of FTP and Web servers operated worldwide by the R community.As of July 2019, the CRAN package repository features 14553 available packages. The R packages are completely free, and we can download it from repositories. 

Bioconductor: This is a topic-specific repository, intended for open source software for bioinformatics. Like CRAN, it has its submission and review processes, and its community is very active, having several conferences and meetings per year. This repository is intended for open source software for bioinformatics. 

GitHub: This is probably the most popular repository for open source projects, although this isn't specific to R. Its popularity comes from the unlimited space for open source, the integration from Git, which are version control software, and its ease to share and collaborate with others.

R-Forge: This is another exciting place to look for packages. The R-Forge site contains projects that are in progress, and it provides tools for developers to collaborate. 

Highest Downloaded Packages in 2019:

R has a good number of packages for Data Analysis, which makes our tasks more straightforward. We can just say that R function and R packages make Data Analysis an easy job. R comes with a standard set of packages. Whenever we need it, we can install packages from repositories. As of today, the CRAN package repository contains around 14550 packages, and the most important point is, these packages are free to download for everyone from the repositories.

A toolkit for working with core R, rlang, andTidyverse feature is in the highest position with 6 M downloads. In the second position, rcpp, which calls c++ code lightning-fast speed, is in the second position with 5M downloads. Data manipulation package, dplyn is in 3rd position with 5M downloads.R’s famous package, ggplot2, which is used for beautiful graphics, is in the 5th position.A convenient tool to format string with multiple variables, glue, is in 7th position with 4.2 Million downloads. Another important package, data.table, is in the 9th position, and finally, R6, an implementation of encapsulated 0/0 programming for R, is in the 10th position.

This section will show the top ten downloaded packages in 2019.

Install and manage Packages:

This part is aimed to help to install and manage R packages. If we want to install any new package, just use install.Packages and in the bracket, packageName, and then run it.

If we want to know the packages already installed in our system, just run installed packages. With the old.packages (), we can check our backdated packages. We can update them by just running update.packages().

And finally, if we are done with packages, we just have to run remove.packages("packageName"). We have to be careful while writing the names of the packages.

Necessary Packages for work:

In this section, we just recommend some packages, which we might try to install with dependencies:

Now, as we know how to install and manage packages, we are right to move forward.