How to fix the there is no package called ‘tidyverse’ error in R?

Today we will learn how to fix error messages that you could find in your R development tool such as RStudio, Jupyter and others, when trying to invoke the tidyverse library without it being installed.

Understanding the error

  • Open RStudio or Jupyter or other R script development environment.
  • Create your script.
  • Invoke the tidyverse environment : library(tidyverse)
  • The Console will return the following exception message:
Error in library(tidyverse) : there is no package called ‘tidyverse’

Here’s a screenshot from the RStudio Console tab in my Windows computer. Same error will be thrown in Ubuntu and macOS.

The root cause is that you are trying to invoke tidyverse but the library is not yet installed in your computer or that there was a problem in the tidyverse installation process. Note that when install the RStudio software, tidyverse is not installed by default and has to be added manually.

Fix the Error in library(tidyverse) in RStudio

Luckily, solving this error is pretty simple: we just need to install tidyverse:

install.packages('tidyverse')

Important Note: Make sure to include the quotation marks around the library name. Failing to do so will invoke the following error: Error in install.packages : object ‘tidyverse’ not found

RStudio will install all the packages that compose the tidyverse such as dplyr, purrr, broom, fs, reprex, highr, selectr, readr, lubridate, stringr etc.

Next, you can go ahead and invoke tidyverse and use any of its sub-packages in your R script:

library(tidyverse)

FAQ

How do i check which version of tidyverse am i running?

In your R Studio condole run the following command to verify the package version of the tidyverse package that you are running.

packageVersion("tidyverse")

If the library is not installed you will receive an error message.

How do i check which R packages i have installed in my environment?

To get a list of all the installed packages, run the following command in R Studio:

installed.packages()

As mentioned, this will return the list of all R packages. In case you would like now to search for tidyverse, you can search the list, or use the following command:

 any (grepl("tidyverse", rownames(installed.packages() )))