Type 'na.omit' and see where it leads.  In this case you see it is an
object class and there are several methods, all of which are not
visible, so you use 'getAnywhere' to see them:

> na.omit
function (object, ...)
UseMethod("na.omit")
<environment: namespace:stats>
> methods(na.omit)
[1] na.omit.data.frame* na.omit.default*    na.omit.ts*

   Non-visible functions are asterisked
> getAnywhere('na.omit.default')
A single object matching 'na.omit.default' was found
It was found in the following places
  registered S3 method for na.omit from namespace stats
  namespace:stats
with value

function (object, ...)
{
    if (!is.atomic(object))
        return(object)
    d <- dim(object)
    if (length(d) > 2)
        return(object)
    omit <- seq_along(object)[is.na(object)]
    if (length(omit) == 0)
        return(object)
    if (length(d)) {
        omit <- unique(((omit - 1)%%d[1]) + 1L)
        nm <- rownames(object)
        object <- object[-omit, , drop = FALSE]
    }
    else {
        nm <- names(object)
        object <- object[-omit]
    }
    if (any(omit > 0L)) {
        names(omit) <- nm[omit]
        attr(omit, "class") <- "omit"
        attr(object, "na.action") <- omit
    }
    object
}
<environment: namespace:stats>
>


On Mon, Oct 27, 2008 at 10:43 AM, useR <[EMAIL PROTECTED]> wrote:
> Hi R helpers,
>
> I'd like to see source code for some of built-in R functions... for
> example, I would like too see how "na.omit" was implemented?
>
>
> Thanks?
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to