1

In R, I'm getting an error "could not find function...". The function is present inside the package. Still when I run the package, getting the error.

I am getting this error in the ChainLadder package while running MackChainLadderFunctions.R. For example, the function checktriangle is present inside the package in Chainladder.R. Still, R is not able to recognize the function or call the function.

Ramesh R
  • 7,009
  • 4
  • 25
  • 38
priya
  • 21
  • 4

1 Answers1

4

Two problems here.

  • function names are case-sensitive (checkTriangle, not checktriangle)
  • checkTriangle is not exported from the package (i.e., it's a private function intended for use within the package only), so you need ::: to access it ... try ChainLadder:::checkTriangle.

Using private functions is "at your own risk/programmer beware"; private functions are undocumented, may change in future versions, etc.. If you can find a way to do what you need to do with public functions, that is generally preferred.

AFAICT you're running into this problem because you're trying to source() (or cut-and-paste) package code in your R session. This shouldn't happen if you load the package with library("ChainLadder") and use the public functions (if it does, please edit your question to give a little more context about how you're using the package ...)

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453