Environments & Finding Functions

from:
https://stat.ethz.ch/pipermail/r-help/2008-November/181143.html


GOAL:  We want to find the source code to function AIC()

QUOTE: 
########################

The AIC() function is not too hard to find
from R.

> AIC
function (object, ..., k = 2) 
UseMethod("AIC")
<environment: namespace:stats>

So now we know that AIC is in the stats package.

> objects("package:stats", all=TRUE)
  [1] ".MFclass"             ".checkMFClasses"      ".getXlevels"          "AIC"                 
  [5] "ARMAacf"              "ARMAtoMA"             "Box.test"             "C"        

so all we are seeing is the AIC generic method shown above.

Very often an S3 method will have a 'default'
method, so let's see if we get lucky:


> stats:::AIC.default
function (object, ..., k = 2) 
{
    ll <- if ("stats4" %in% loadedNamespaces()) 
    ......
.
.
.
########################
