Re: [R] source code functions

From: Gavin Simpson <>
Date: Fri, 18 Jul 2008 14:48:55 +0100

On Fri, 2008-07-18 at 09:37 -0400, stephen sefick wrote:
> >na.contiguous
> function (object, ...)
> UseMethod("na.contiguous")
> <environment: namespace:stats>
> this is what I get when I look for the source code for some functions- Is
> there a way to look at the source code?

na.contiguous is an S3 generic function, and that *is* the source for it! To see what methods are available, used methods():

> methods(na.contiguous)
[1] na.contiguous.default*

   Non-visible functions are asterisked

To see the code in the available method, you need to access it in the relevant namespace as it is hidden from the user:

> na.contiguous.default

Error: object "na.contiguous.default" not found
> getAnywhere(na.contiguous.default)

A single object matching ‘na.contiguous.default’ was found It was found in the following places
  registered S3 method for na.contiguous from namespace stats   namespace:stats
with value

function (object, ...)

?UseMethod would have got you there.

See Uwe Ligges RNews article on this very subject:


 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e]
 Gower Street, London          [w]
 UK. WC1E 6BT.                 [w]

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 18 Jul 2008 - 14:26:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 18 Jul 2008 - 15:02:01 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive