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
What Is Onion Over VPN? Is It Safe to Set Up and Use in 2024?
Bitcoin mining has 'very worrying' impacts on land and water, not only carbon
Kem Minnick Playboy
Skycurve Replacement Mat
Promotional Code For Spades Royale
Busted Newspaper Zapata Tx
Instructional Resources
J & D E-Gitarre 905 HSS Bat Mark Goth Black bei uns günstig einkaufen
Frank Lloyd Wright, born 150 years ago, still fascinates
80 For Brady Showtimes Near Marcus Point Cinema
Wmu Course Offerings
Sam's Club Gas Price Hilliard
Missing 2023 Showtimes Near Lucas Cinemas Albertville
Jessica Renee Johnson Update 2023
Thotsbook Com
Google Flights Missoula
Water Days For Modesto Ca
Vigoro Mulch Safe For Dogs
Evil Dead Rise Showtimes Near Regal Sawgrass & Imax
Sussyclassroom
Pearson Correlation Coefficient
Sister Souljah Net Worth
Dei Ebill
Dove Cremation Services Topeka Ks
Marilyn Seipt Obituary
Maisons près d'une ville - Štanga - Location de vacances à proximité d'une ville - Štanga | Résultats 201
A Man Called Otto Showtimes Near Carolina Mall Cinema
24 Hour Drive Thru Car Wash Near Me
Lininii
King Soopers Cashiers Check
Grays Anatomy Wiki
Emiri's Adventures
Miss America Voy Board
T&J Agnes Theaters
Unity Webgl Player Drift Hunters
Jefferson Parish Dump Wall Blvd
Grapes And Hops Festival Jamestown Ny
Indiefoxx Deepfake
Quake Awakening Fragments
Greater Keene Men's Softball
Duff Tuff
Unifi Vlan Only Network
Blackwolf Run Pro Shop
The Banshees Of Inisherin Showtimes Near Reading Cinemas Town Square
Craigslist Freeport Illinois
Unitedhealthcare Community Plan Eye Doctors
Walmart 24 Hrs Pharmacy
Sky Dental Cartersville
Nfsd Web Portal
Chitterlings (Chitlins)
Psalm 46 New International Version
Cbs Scores Mlb
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.