1

I am trying to view the source code of the function knnreg in caret.

> getAnywhere(knnreg.default)
A single object matching ‘knnreg.default’ was found
It was found in the following places
  package:caret
  registered S3 method for knnreg from namespace caret
  namespace:caret
with value

function (x, ...) 
{
    if (!any(class(x) %in% "formula")) 
        stop("knnreg only implemented for formula objects")
}
<environment: namespace:caret>

What's happening? Where is the source code?

Richie Cotton
  • 118,240
  • 47
  • 247
  • 360
thecheech
  • 2,041
  • 3
  • 18
  • 25
  • 2
    Have a look at [**this nice post**](http://stackoverflow.com/questions/19226816/how-can-i-view-the-source-code-for-a-function/19226817#19226817) – Henrik Mar 24 '14 at 08:52

1 Answers1

4

I think the error message is pretty obvious:

knnreg only implemented for formula objects

Use getAnywhere(knnreg.formula) to see the source code.

Roland
  • 127,288
  • 10
  • 191
  • 288