How can I manage R packages? (2024)

R is a statistical software made up of many user-written packages. The base version of R that is downloaded allows the user to get started in R, but anyone performing data analysis will quickly exhaust the capabilities of base R and need to install additional packages. Here are some basic commands for managing R packages.

Which packages do I already have?

To see what packages are installed, use the installed.packages() command. This will return a matrix with a row for each package that has been installed. Below, we look at the first 5 rows of this matrix.

installed.packages()[1:5,] Package LibPath Version Priority base "base" "C:/PROGRA~1/r/R-211~1.1/library" "2.11.1" "base" boot "boot" "C:/PROGRA~1/r/R-211~1.1/library" "1.2-42" "recommended"car "car" "C:/PROGRA~1/r/R-211~1.1/library" "2.0-2" NA class "class" "C:/PROGRA~1/r/R-211~1.1/library" "7.3-2" "recommended"cluster "cluster" "C:/PROGRA~1/r/R-211~1.1/library" "1.12.3" "recommended" Depends Imports LinkingTobase NA NA NA boot "R (>= 2.9.0), graphics, stats" NA NA car "R (>= 2.1.1), stats, graphics, MASS, nnet, survival" NA NA class "R (>= 2.5.0), stats, utils" "MASS" NA cluster "R (>= 2.9.0), stats, graphics, utils" NA NA Suggests Enhances OS_type License Built base NA NA NA "Part of R 2.11.1" "2.11.1"boot "survival" NA NA "Unlimited" "2.11.1"car "alr3, leaps, lmtest, sandwich, mgcv, rgl" NA NA "GPL (>= 2)" "2.11.1"class NA NA NA "GPL-2 | GPL-3" "2.11.1"cluster NA NA NA "GPL (>= 2)" "2.11.1"

From this output, we will first focus on the Package and Priority columns. The Package column gives the name of the package and the Priority column indicates what is needed to use functions from the package.

  • If Priority is "base", then the package is already installed and loaded, so all of its functions are available upon opening R.
  • If Priority is "recommended", then the package was installed with base R, but not loaded. Before using the commands from this package, the user will have to load it with the library command, e.g. library(boot).
  • If Priority is NA, then the package was installed by the user, but not loaded. Before using the commands from this package, the user will have to load it with the library command, i.e., library(car).

Have I installed a specific package?

Sometimes, you might want to know if you have already installed a specific package. Let’s say we want to check if we have installed the package "boot". Instead of checking the entire list of installed packages, we can do the following.

a<-installed.packages()packages<-a[,1] is.element("boot", packages)
[1] TRUE

How can I add or delete packages?

Any package that does not appear in the installed packages matrix must be installed and loaded before its functions can be used. A package can be installed using install.packages("<package name>"). A package can be removed using remove.packages("<package name>").

What packages are available?

The list of available R packages is constantly growing. The actual list can be obtained using available.packages(). This returns a matrix with a row for each package.

p <- available.packages()dim(p)[1] 2553 12p[1:5,] Package Version Priority Depends ImportsACCLMA "ACCLMA" "1.0" NA NA NA ADGofTest "ADGofTest" "0.1" NA NA NA AER "AER" "1.1-7" NA "R (>= 2.5.0), stats, car (>= 2.0-1), Formula (>= 0.2-0),nlmtest, sandwich, strucchange, survival, zoo" "stats"AGSDest "AGSDest" "1.0" NA "ldbounds" NA AICcmodavg "AICcmodavg" "1.11" NA NA NA LinkingToACCLMA NA ADGofTest NA AER NA AGSDest NA AICcmodavg NA Suggests ACCLMA NA ADGofTest NA AER "boot, dynlm, effects, foreign, ineq, KernSmooth, lattice,nMASS, mlogit, nlme, nnet, np, plm, pscl, quantreg, ROCR,nsampleSelection, scatterplot3d, systemfit, rgl, truncreg,ntseries, urca"AGSDest NA AICcmodavg "lme4, MASS, nlme, nnet" Enhances OS_type License File Repository ACCLMA NA NA "GPL-2" NA "http://cran.stat.ucla.edu/bin/windows/contrib/2.11"ADGofTest NA NA "GPL" NA "http://cran.stat.ucla.edu/bin/windows/contrib/2.11"AER NA NA "GPL-2" NA "http://cran.stat.ucla.edu/bin/windows/contrib/2.11"AGSDest NA NA "GPL (>= 2)" NA "http://cran.stat.ucla.edu/bin/windows/contrib/2.11"AICcmodavg NA NA "GPL (>= 2 )" NA "http://cran.stat.ucla.edu/bin/windows/contrib/2.11"

These first five (of 2,553) available packages illustrate that the package names are often acronyms and rarely reveal what the package functions do. A list of the packages available through CRAN including a short package description can be found at CRAN’s Contributed Packages page.

What functions and datasets are in a package?

It is easy to access some quick documentation for a package from R with the help command. This opens an R window with package information followed by a list of functions and datasets.

help(package="MASS")

How can I manage R packages? (1)

Once a package is loaded, the help command can also be used with all functions and datasets listed here, e.g. help(Null).

How can I manage R packages? (2024)
Top Articles
Airbnb Cleaning Checklist Guide & Template
Top Up Dash Wallet | All-in-one Mobile Wallet | Singtel Dash
Golden Grain Pizza East Greenbush - Rensselaer
60+ Free Perler Bead Patterns and Craft Ideas - Fun Loving Families
Tory Lanez Chixtape 5 Download Fakaza
Field Box 38 Fenway
Reyes Holdings - 6th Largest Privately Owned Company in US
Li Bai - New World Encyclopedia
Academy Sports Plano Tollway
los angeles cars & trucks - by owner "used cars" - craigslist
Rumsey Yost Funeral Home Obituaries
Kenzie Reeves Wikipedia
Barbra Jane Dovey
Craigslist Kansas City Auto Parts
Technische Informatica | Studeren bij hogeschool Saxion | Hogeschool Saxion
Elevating security and disease forecasting in smart healthcare through artificial neural synchronized federated learning
State Road 38 Garage Sale Indiana 2023
Thrive Dispensary in Harrisburg, IL
Visiting Truist Park: This Is What You Need to Know
Cavallo Terrace Rv Park
Natalie Roush dild*
Scooter Tramps And Beer
Guide to How Long A Tire Lasts
Dallas Cowboys On Sirius Xm Radio
Ficoforum
Dr. John J. Carroll - California Sports Psychology | LinkedIn
Company doctor or health and safety service
Embassy Suites Wisconsin Dells
Dance Monkey Roblox Id
Ups Access Point Lockers
Fuuuuck*
Kreme Delite Menu
Why did Sean 'Diddy'​ Combs give me his mobile number?
Www Craigslist Com Corpus Christi
Michael Zhang Cooley
Ups Locations Massachusetts
Wheely 6 Abcya
Different Types of Conditional Sentences in English: Definition and Examples | Proofreading
Antiterrorism Level 1 Pretest Answers
417-990-0201
My Juno Personal Start Page
Tamil Dubbed Movie Download Kuttymovies
Milkhater05 Of
Troll Hunter Wiki
Tropical Smoothie Delivery Near Me
Portugal Anúncios Classificados OLX
Amazon Gru Costume
Wat betekenen cringe en awkward? - Youngworks
Craigslist Campers For Rent
Luxiconic Nails
Quiktrip Gas Price Today
Kwik Trip Okta App
Latest Posts
Article information

Author: Van Hayes

Last Updated:

Views: 5927

Rating: 4.6 / 5 (66 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Van Hayes

Birthday: 1994-06-07

Address: 2004 Kling Rapid, New Destiny, MT 64658-2367

Phone: +512425013758

Job: National Farming Director

Hobby: Reading, Polo, Genealogy, amateur radio, Scouting, Stand-up comedy, Cryptography

Introduction: My name is Van Hayes, I am a thankful, friendly, smiling, calm, powerful, fine, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.