RStudio
Getting Started in RStudio
If you are new to RStudio, the RStudio User Guide - Get Started page provides a good overview of the interface and has step-by-step exercises you can perform to become familiar with the basics of RStudio.
R Packages
Packages contain code, data, and documentation in a standardized collection format that you can install to perform specific tasks or operations within your code.
R is a programming language and software environment for statistical computing and graphics. R and its libraries implement a wide variety of statistical and graphical techniques, such as linear and non-linear modeling, classical statistical tests, time-series analysis, classification, and clustering.
R is easily extensible through functions and extensions. The R community is noted for its active contributions to developing R packages. R packages contain code, data, and documentation in a standardized collection format that R users can install. R and R packages are available via the Comprehensive R Archive Network (CRAN), a collection of sites that carry the R distribution(s), the contributed extensions, documentation for R, and binaries.
Available Packages
A list of available packages in CRAN can be found in the CRAN package repository. From the CRAN package repository, you can click on a package and learn more about it and access its documentation.
You can also view a list of available packages from your JupyterLab environment. To view the list of available packages in CRAN, run the available.packages()
command in a notebook or console. If you want to view a subset of the list, you can append [first-row-number:last-row-number]
to the command. For example, to view the first 100 available packages, the command is:
available.packages()[1:100]
How to Install Packages from CRAN
To install an available package from CRAN, use the install.packages('PACKAGE_NAME')
command, replacing PACKAGE_NAME
with the name of the package you want to install. For example, to install the package abc
, the command is:
install.packages('abc')
How to Install Packages from GitHub
To install a package from GitHub that is not available in CRAN, you can use the CRAN githubinstall package. See the githubinstall reference manual for more details on how to use this package.
Installed Packages
To check if a single package is installed, use the below code, replacing PACKAGE_NAME
with the name of the package you want to check. If the package is installed, the code will return TRUE
; if it is not installed, it will return FALSE
.
a<-installed.packages() packages<-a[,1] is.element('PACKAGE_NAME', packages)Reference: UCLA OARC Stats
To view a list of installed packages, run the installed.packages()
command in a notebook or console. If you want to view a subset of the list, you can append [first-row-number:last-row-number]
, to the command. For example, to view the first 100 installed packages, the command is:
installed.packages()[1:100]