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.
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?
I got the same, error, I was running version .99xxx, I checked for updates from help menu and updated My RStudio to 1.0x, then the error did not come
So simple solution, just update your R Studio
Another problem, in the presence of a NAMESPACE, is that you are trying to run an unexported function from package foo.
For example (contrived, I know, but):
Firstly, you shouldn't be calling S3 methods directly, but lets assume
plot.prcomp
was actually some useful internal function in package foo. To call such function if you know what you are doing requires the use of:::
. You also need to know the namespace in which the function is found. UsinggetAnywhere()
we find that the function is in package stats:So we can now call it directly using:
I've used
plot.prcomp
just as an example to illustrate the purpose. In normal use you shouldn't be calling S3 methods like this. But as I said, if the function you want to call exists (it might be a hidden utility function for example), but is in a namespace, R will report that it can't find the function unless you tell it which namespace to look in.If you are using
parallelMap
you'll need to export custom functions to the slave jobs, otherwise you get an error "could not find function ".If you set a non-missing level on
parallelStart
the same argument should be passed toparallelExport
, else you get the same error. So this should be strictly followed:I can usually resolve this problem when a computer is under my control, but it's more of a nuisance when working with a grid. When a grid is not homogenous, not all libraries may be installed, and my experience has often been that a package wasn't installed because a dependency wasn't installed. To address this, I check the following:
.libPaths()
is a good check.ldd
results for R, to be sure about shared librariesHaving encountered this quite a bit, some of these steps become fairly routine. Although #7 might seem like a good starting point, these are listed in approximate order of the frequency that I use them.