The possible reasons for getting this error 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.