Lets 'Start with Why' ....'Why a concept of Package exists in R ' -
R is built on the ethos of 'Sharing & Building Together ' which essentially means -
a global community of Experts & Enthusiasts are constantly adding / sharing new features / capabilities of R.
These new enhancements get shared with the R community through 'Packages' being made available at a Central Official Repository.
Availability of these additional Packages increases the Power of R by improving upon the existing base R functionalities.
So , What is a Package in R then ...
In R , the fundamental unit of Shareable code is called a Package .
A Package bundles together Code , Data , Documentation & easy to share with others.
The Description or Documentation of a Package can be retrieved in R using following commands -
R Command to show the Package Description
R Command to show the Package Documentation
> help( package = 'mosaic')
And Where is the Central Official Repository of Publicly shared Package in R ...
CRAN ( Comprehensive R Archive Network ) is the official repository , it is a network of ftp & web servers being maintained by the R community around the world.
This repository is maintained & coordinated by R Foundation & for a package to be published here , it needs to pass several stringent tests demonstrating that the Package is following CRAN policies.
CRAN Website :https://cran.r-project.org/
How many R Packages are available as on Nov 2018
> nrow(available.packages()) # Total Number of R Packages available as on Nov 2018
Now , lets discuss the final aspect of this article - How to Install & Load packages -
a) Before we Install a Package , lets check whether a Package is already installed or not -
Below 2 commands ( either of them ) will list down all Installed Packages in your R Environment
b) How to Install Package which is not already installed ..
Package Installation is a process by which a Package available in Central Repository ( Like CRAN ) gets downloaded from Web Central Repository and added to your R Local Library ( on your system ) .
Hence , to install packages , it is prerequisite that you have internet connectivity.
Below R command will Install 'dplyr' package along with all the dependent Packages.
> install.packages('dplyr' , dependencies = T)
c) We have Installed a Package , but how to Load the Package to the memory and have the objects in Package made available to R Environment instance ..
The Packages can be loaded to memory by 2 ways -
After loading the Packages using above methods , you can now access all Objects in the library directly .
d) How to check the list of Packages Loaded into Memory
 ".GlobalEnv" "package:mosaic" "package:Matrix" "package:mosaicData"
 "package:ggformula" "package:ggstance" "package:ggplot2" "package:lattice"
 "package:titanic" "package:bindrcpp" "package:dplyr" "tools:rstudio"
 "package:stats" "package:graphics" "package:grDevices" "package:utils"
 "package:datasets" "package:methods" "Autoloads" "package:base"
e) How to unload a Package from the memory ( so as to make space in memory by removing the unused Package )
> detach("package:mosaic" , unload=T)
f) How to remove an Installed Package which is no more needed
Removing package from ‘D:/Users/prmohant/Documents/R/R-3.5.1/library’
(as ‘lib’ is unspecified)
g) How to find the list of Installed Packages which are older than the latest version available at Web Central Repository
h) How to update all the old packages installed on your system
Other R commands / functions related to package handling
1) Get the System Folder Path where R Packages are stored on your System
Thank You & Happy Learning !!