Error: could not find function … in R

733    Asked by JackRussell in Data Science , Asked on Jul 15, 2021

 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?


Answered by Alison Kelly

The possible reasons for getting r could not find function error solved are as follows:

You did not spell the function name correctly.

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

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

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.



Your Answer

Interviews

Parent Categories