Video Notes
When you encounter the error could not find function
in R, it means R doesn’t know where to find the function you’re trying to use. Below are two common reasons this happens and how to fix the problem.
You need to load the package
Many functions live inside specific packages. If you don’t load the package into your current R session, R doesn’t know the function exists.
Here’s an example attempting to use the glimpse function from the dplyr package, before the dplyr package has been loaded in the current session:
To address this, you need to load the dplyr package into your current R session via the library command:
library(dplyr)
If this yields an error telling you there is no package called dplyr, it means you have not yet installed that package on your computer:
Error in library(dplyr) : there is no package called ‘dplyr’
To address that, use install.packages
(make sure you surround the package name in quotes):
install.packages("dplyr")
Then re-run the library command:
library(dplyr)
FYI
If you’re unsure what package a function belongs to, try searching online or asking an AI program “What R package does [function name] belong to?”
Check spelling and case
Another common reason you might encounter a could not find function error in R is because function names are case-sensitive and must be spelled exactly right.
For example, Glimpse(mtcars)
will not work, even if the dplyr package is loaded. You must use the correct lowercase spelling: glimpse(mtcars)
.
Unlock all notes for $4
For $4, you’ll get 6 months of unlimited access to the notes for the above video
and all of my other 200+ guides and videos.
This is a one-time payment— no subscriptions or auto-renewals to worry about cancelling.
Your support helps me continue creating free, high-quality videos. Thank you!