LOADING

Type to search

R Packages

To Know more about the Different Corporate Training & Consulting Visit our website www.Instrovate.com Or Email : info@instrovate.com or WhatsApp / Call at +91 74289 52788

R Programming

R Packages

Share

R Packages are collections of R functions, data, and compiled code in a well-defined format. The directory where packages are stored is called the library. R comes with a standard set of packages. Others are available for download and installation. Once installed, they have to be loaded into the session to be used.

R comes with standard (or base) packages, which contain the basic functions and data sets as well as standard statistical and graphical functions that allow R to work easily.

The packages are stored in three sources mainly –

1. CRAN

2. Bioconductor

3. Github

CRAN :

The full form of CRAN is Comprehensive R Archive Network. It is an open source platform to store packages and other documents related to R. It is an open distributed platform , where anyone can store and download packages . It is default source to install packages in R.

Bioconductor:

Bioconductor is a freeopen source and open development software project for the analysis and comprehension of genomic data generated by wet lab experiments in molecular biology.

Github:

It is a web based repository to store and collaboration features for development . We can store packages in this repository .

You can install package by following these steps :

1. Go to Package tab in right corner window . Choose Install option from the Package menu .

R Packages 29

2. It will open Install Packages window .

R Packages 30

3. Add package name under Packages(separate multiple with space or comma) . Add ggplot2 package to install.

R Packages 31

4. I am installing package ggplot2 here . Click on Install button to install package.

5. It will show following output in Console window .  

R Packages 32

You can also install packages by using Script window. We can write this code to install “ggplot2” package.

install.packages(“ggplot2”)

R Packages 33

To load “ggplot2” package we can write following code:

library(ggplot2)

When we run this command , it will show this output  .

R Packages 34

We can also load “ggplot2” package by using another way :

We search ggplot2 in Package window . It will show this window.

R Packages 35

For loading ggplot2 package , we tick mark ggplot2 . It will load ggplot2 package .

You can see output here :

R Packages 36

If we unselect (un-tick) mark across ggplot2 , it will unload package from R .We can see the output here :

R Packages 37

It shows following code in Console window :

detach(“package:ggplot2”,unload=TRUE)

It shows we detach package from R by above code or by just un-tick ggplot2 from package window.

You can also download multiple packages at the same time :

install.packages(c(“ggplot2″,”dplyr”))

Install a package from Bioconductor :

First , we install Bioconductor package by :-

source(“https://bioconductor.org/biocLite.R”)

R Packages 38

To install package “limma” from Bioconductor source :

biocLite(“limma”)

R Packages 39

Install a package from Github :

First install “devtools” package.

install.packages(“devtools”)

R Packages 40

We are installing “survminer” package here :

devtools::install_github(“kassambara/survminer”)

In above code kassambara is User-name of github user . Survminer is package stored in github repository of  kassambara(User ).

R Packages 41

R Packages 42

R Packages 43

View loaded R packages :

To view the list of loaded (or attached) packages during an R session, use the function search():

search()

R Packages 44

Remove installed packages :

To remove an installed R package , we are using remove.packages() as follow:

remove.packages(“fpc”)

It will remove “fpc” package from R.

Update installed packages :

If you want to update all R packages, type this:

update.packages()

To update specific installed packages  “readr “and “ggplot2“, use this:

update.packages(oldPkgs = c(“readr”, “ggplot2”))