R Packages

Question: What is an R Package?
Answer: R package 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 do I see which packages I have available?
Answer: To see which packages you have to use the command at the R prompt

> library()

Question: Which packages do I already have?
Answer: To see what packages are installed one can use the installed.packages() command a R prompt. The output will show the packages installed.

> installed.packages()
> installed.packages()[1:5,]

Question: How one can load a Package in R language?
Answer: Basic packages are already loaded. If you want to load a downloaded version of packages use the command

> library(“package name”)
> library(“car”)

where package name is the name of the package you want to load. Here in the example, we used the “car”, it means “car” package will be loaded.

Question: How one can see the documentation of a particular package?
Answer: To see the documentation of particular package use the command

> library(help=”package name”)
> help(package=”package name”)
> help(package=”car”)
> library(help=”car”)

for more information about getting help follow the link: Getting Help in R Language

Question: How do I see the help for a specific function?
Answer: To get help about a function in R use command

> help(“function name”)
> ? function name
> ?Manova
> help(“Manova”)

Question: What functions and datasets are available in a package?
Answer: To check what functions and datasets are in a package using the help command at R prompt. This will provide package information giving a list of functions and datasets.

> help(package = “MASS”)

Note that once a package is loaded, the help command can also be used with all available functions and datasets.

Question: How can one add or delete a package?
Answer: A package can be installed using command

> install.packages(“package name”)

and package can be removed or deleted using command

> remove.packages(“package name”)