Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (7.3k points)
edited by

I am using R and tried some.function but I got following error message: 

Error: could not find function "some.function"

This question comes up very regularly. When you get this type of error in R, how can you solve it?

2 Answers

0 votes
by
edited by

The possible reasons for getting this error are as follows:

  1. You did not spell the function name correctly.

  2. The function is contained in a library which is not installed.

  3. The library of the function is not loaded with either library() or require().

  4. The version of R you are using is obsolete where that function does not exist.

You can use the following code to check the package in which the function is contained:

help.search("function_name") or ??function_name

To find the function, use the following functions:

find(function_name)

OR

getAnywhere(function_name)

You can also use the findFn from the sos package to display the packages containing the function as follows:

install.packages("sos") library("sos") findFn("function_name")

It will open a web page that will show all the libraries where the function is contained.

0 votes
by (50.2k points)

This error usually occurs when a package has not been loaded into R via the library, so R does not know where to find the specified function. It’s a good practice to use the library functions on all of the packages you will be using in the top R chunk in your R Markdown file, which is usually given the chunk name setup.

Related questions

Browse Categories

...