Joris Meys Joris Meys - 4 months ago 20
R Question

Error: could not find function ... in R

I am using R and tried

but I got this error message :

Error: could not find function `some.function`

This question comes up very regularly. When you get the
error: could not find function
in R, how can you solve it?

Thank you in advance for your help.

This is meant to be a FAQ question, so please be as complete as possible. The answer is a community answer, so feel free to edit if you think something is missing.

This question is approved on meta:


There are a few things you should check :

  1. Did you write the name of your function correctly? Names are case sensitive.
  2. Did you install the package that contains the function? install.packages("thePackage") (this only needs to be done once)
  3. Did you attach that package to the workspace ? require(thePackage) or library(thePackage) (this should be done every time you start a new R session)

If you're not sure in which package that function is situated, you can do a few things.

  1. If you're sure you installed and attached/loaded the right package, type"some.function") or ??some.function to get an information box that can tell you in which package it is contained.
  2. find and getAnywhere can also be used to locate functions.
  3. If you have no clue about the package, you can use findFn in the sos package as explained in this answer.
  4. RSiteSearch("some.function") or searching with rseek are alternative ways to find the function.