Skip to main content
v2026.11,858 entries · CC-BY 4.0
LAC HealthMedical & Research SuppliesReagents, PPE & instruments — chain-of-custody documented.Fast, traceable sourcing built for regulated research environments, from bench consumables to instrumentation.Shop lac.us CodeCASRAIlac.us

How to Install R Packages (CRAN, Bioconductor, GitHub)

Install R packages from CRAN, Bioconductor and GitHub with the exact commands, see where they land, and fix compiled-package failures.

Written and maintained by CASRAI Editorial Board

Last updated

To install an R package from CRAN, run install.packages("name") in the R console, then load it with library(name) in each session that needs it. Packages from Bioconductor go through BiocManager::install(), and packages hosted on GitHub install with pak::pkg_install("owner/repo"). This guide covers all three routes, where the files end up on disk, and why compiled packages sometimes fail to install.

What installing packages is used for in research

Base R ships with a core set of functions; most statistical methods, plotting systems and field-specific tools arrive as add-on packages. Installing a package downloads it once to a library folder on your machine. Loading it with library() is a separate step you repeat each session. Recording which packages and versions an analysis used is a reproducibility matter, covered in the renv guide; for the wider language context see what R is used for.

Install or access (official sources only)

You need R itself first. The R manual “R Installation and Administration” states that for most users calling install.packages() is enough, and that it also fetches the essential dependencies a package declares. An editor such as RStudio is optional; see how to use RStudio or RStudio in the cloud if you prefer a browser.

Step-by-step: install a package from CRAN

  1. Open R (or the RStudio console).
  2. Run install.packages("tibble"), replacing tibble with the package name. The pkgs argument is a character vector, so several packages can be installed at once: install.packages(c("tibble", "readr")).
  3. Wait for the download and any dependencies to finish. By default dependencies are the packages listed under Depends, Imports and LinkingTo.
  4. Load the package in every session where you use it: library(tibble).

If you call install.packages() with no package names in an interactive session, R shows a list to choose from instead.

Install from Bioconductor

Bioconductor packages are installed through the BiocManager package rather than directly. The Bioconductor install page gives this sequence:

  1. if (!require("BiocManager", quietly = TRUE)) install.packages("BiocManager")
  2. BiocManager::install(version = "3.23") to set up the release that matches your R. As of 2026-10-29 the page states that Bioconductor 3.23 works with R 4.6.0.
  3. BiocManager::install(c("GenomicFeatures", "AnnotationDbi")), replacing the names with the packages you need.

Install from GitHub and other sources

The pak package installs from CRAN, Bioconductor, GitHub, URLs, git repositories, local files and directories. Install pak once with install.packages("pak"), then:

  • CRAN: pak::pkg_install("tibble")
  • GitHub (owner/repo form): pak::pkg_install("tidyverse/tibble")

To install from a local file, install.packages() accepts repos = NULL, which installs from local files or URLs instead of a repository. On Unix-alikes, a source package can also be installed from the terminal with R CMD INSTALL.

Where packages are installed

If you do not give a lib argument, packages go into the first directory returned by .libPaths(). Run .libPaths() to see where that is on your machine. If that folder is not writable, then in interactive use R offers to create a personal library, which is the first element of Sys.getenv("R_LIBS_USER"). The R manual notes that on Windows, detecting whether a folder is writable is not always reliable. Library lists in the environment variables R_LIBS_USER and R_LIBS_SITE are separated by colons, or by semicolons on Windows.

Output and how to read it

A successful install prints download and installation messages for the package and any dependencies, and returns you to the prompt. The practical test is whether library(name) runs without an error. A message that a package was installed to a personal library means the system folder was not writable, which is normal on shared machines.

Troubleshooting

Why compiled packages fail to install

Packages containing C, C++ or Fortran code need a toolchain when installed from source. According to the R manual: on Windows, binary packages are preferred when available, and source packages with compiled code need Rtools; on macOS, source packages with C, C++ or Fortran code need matching compilers. Most binary packages with compiled code are tied to an R release series (for example 4.5.x), so after upgrading R to a new series you reinstall them.

The library is not writable

Accept the personal-library prompt in an interactive session, or point lib at a folder you own. Check the result with .libPaths().

A package is “not available”

The package may live on Bioconductor or GitHub rather than CRAN; use the matching route above.

Free alternatives (table)

Tool Installs from Example
install.packages() Repositories such as CRAN; local files and URLs with repos = NULL install.packages("tibble")
BiocManager::install() Bioconductor BiocManager::install("AnnotationDbi")
pak::pkg_install() CRAN, Bioconductor, GitHub, URLs, git repositories, local files pak::pkg_install("tidyverse/tibble")
R CMD INSTALL A source package, from the terminal (Unix-alikes) See the R manual

For a wider view of free tools, see the free statistical software guide.

FAQ

Do I need to install a package every time I use R?

No. Install once; run library(name) in each new session.

Can I install several packages at once?

Yes. Pass a character vector: install.packages(c("tibble", "readr")).

How do I install a package that is not on CRAN?

Use BiocManager::install() for Bioconductor or pak::pkg_install("owner/repo") for GitHub.

Sources (official docs)

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about How to Install R Packages (CRAN, Bioconductor, GitHub)

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →