R Packages: An Introduction

Question: What version of R do I run on my computer or laptop?

Answer: To get the information about the version of R, use the following command at R prompt.

> # get a version of R
> R.version.string

You will get a result like

[1] “R version 3.2.1 (2015-06-18)”

Note that a package in R language is a collection of objects that R Language can use. A package contains functions, data set, and documentation (which helps how to use the package) or other objects such as dynamically loaded libraries of already compiled code.

Question: How to check what packages are already installed?

Answer: To get a list of installed packages in R, write “library()” without quotation marks at the R prompt. R will first list all of the packages installed in the local R directory of your computer system and then it will list all packages installed globally on your computer system.

# list all packages installed

You would get results like (note that results below are given as an example only, it’s not a complete list)

Packages in library ‘C:/Users/abcd/Documents/R/win-library/3.2’:
combinat     combinatorics utilities
proftools      Output Processing Tools for R
rgl                  3D visualization device system (OpenGL)

Packages in library ‘C:/Program Files/R/R-3.2.1/library’:
KernSmooth      Functions for kernel smoothing for Wand & Jones (1995)
MASS                   Support Functions and Datasets for Venables and Ripley’s MASS
Matrix                  Sparse and Dense Matrix Classes and Methods
methods              Formal Methods and Classes
mgcv                    Mixed GAM Computation Vehicle with Automatic
Smoothness Estimation

Following is a very short list of packages installed in the local library.

Packages in library ‘C:/Users/imdad/Documents/R/win-library/3.5’:

abind               Combine Multidimensional Arrays
AlgDesign      Algorithmic Experimental Design
askpass          Safe Password Entry for R, Git, and SSH
assertthat      Easy Pre and Post Assertions
tibble               Simple Data Frames
plyr                  Tools for Splitting, Applying and Combining Data

Available R Packeges in Local and Global Directory

For further detail on packages in R, see the link Packages in R Language.