R Package Questions and Answers

The post is about some important R package questions and answers. The R Package Questions and Answers are about how to load, install, and remove an R package.

R Package Questions and Answers

Question: What is an R Package?
Answer: The r package is a collection of objects that the R Language can use. A package contains functions, data sets, 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 an R prompt. The output will show the packages installed.

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

Loading R Packages

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 the package name is the name of the package you want to load. Here in the example, we used the “car”, which means the “car” package will be loaded.

Getting Help in R Language

Question: How one can see the documentation of a particular package?
Answer: To see the documentation of a 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 with a function in R use the 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 the 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.

Installing and Removing R Packages

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

install.packages("package name")

and a package can be removed or deleted using the command

remove.packages("package name")
R Packages Questions and Answers R Faqs

Computer MCQs Test Online

SPSS Data Analysis

R Packages: An Introduction

The post is about R Packages in the form of Questions and Answers.

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 the 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 sets, and documentation (which helps how to use the package) or other objects such as dynamically loaded libraries of already compiled code.

Installing R Packages

Question: How to check what packages are already installed?

Answer: To get a list of installed packages, write “library()” without quotation marks at the prompt. You will see the list of 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
library( )

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

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

R packages are essentially a combination of reusable code, documentation, and code that extend the power and capabilities of the R programming language. R packages are designed to be easily installed and used. The R packages are a major reason why R is so popular in data science. There are tens of thousands of R packages available on CRAN and other repositories, covering a wide range of tasks, from data manipulation and analysis to visualization and modeling.

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

Learn Basic Statistics