When you use an R function in Exploratory, you may see an error message like the following:
could not find function "xxxxx"
This error means that “a function with the specified name could not be found.”
If you get this error even though there is no typo in the function name, the cause generally falls into one of the following two cases. Since the fix differs for each, first identify which case you are dealing with.
- The R package that contains the function you want to use is not loaded in the project
- The custom function (custom R script) you want to use is not registered in the project
Case 1: The R Package Is Not Loaded
Many R functions, such as Gini or distHaversine, are included in specific packages. If the package that contains the function is not loaded in your project, you will get the could not find function error even when the function name is correct.
For the detailed steps on how to resolve this case, please refer to the existing post below.
Case 2: The Custom Function (Custom R Script) Is Not Registered
In Exploratory, you can define frequently used operations as a custom function (custom R script) and call it within your project. When you try to use such a custom function, you can get exactly the same could not find function error as with a package function.
In this case, no matter how many R packages you install, the problem will not be solved. The cause is that the custom function is not registered in the project. For example, this happens in situations like the following:
- You haven’t yet created/registered the custom function, but you’re already using the function name in a command
- You created the custom function in another project, but you haven’t registered it in your current project
For how to create and register custom functions, please refer to the note below.