

   Methods {base}                               R Documentation

   IInntteerrnnaall aanndd GGrroouupp MMeetthhooddss aanndd GGeenneerriicc FFuunnccttiioonnss

   DDeessccrriippttiioonn::

        Many R-internal functions  are generic and  allow meth-
        ods to be written for.  Group methods in particular are
        available for the `"Math"',  `"Ops"', and `"Summary"'
        group.

   UUssaaggee::

        Math.data.frame(x, ...)
        Math.factor(x, ...)

        Ops.data.frame(e1, e2 = NULL)
        Ops.factor(e1, e2)
        Ops.ordered(e1, e2)

        Summary.data.frame(x, ...)
        Summary.factor(x, ...)

        .Method
        .Generic
        .Group
        .Class

   GGrroouupp DDiissppaattcchhiinngg::

        There are three groups for which methods can be writ-
        ten, namely the `"Math"', `"Ops"' and `"Summary"'
        groups.

        A function `f' belonging to one of these groups must be
        `.Internal' or `.Primitive' and will automatically be
        using `<grp>.<class> (ob)' when `f(<ob>)' is called,
        `f' belongs to group `<grp>' and `<ob>' is of `class'
        `<class>'.

           * Group `"Math"':

                * `abs', `sign', `sqrt',
                  `floor', `ceiling', `trunc',
                  `round', `signif'

      * `exp', `log',
        `cos', `sin', `tan',
        `acos', `asin', `atan'

        `cosh', `sinh', `tanh',
        `acosh', `asinh', `atanh'

      * `lgamma', `gamma', `gammaCody',
        `digamma', `trigamma', `tetragamma', `pentagamma'

      * `cumsum', `cumprod', `cummax', `cummin'

      * Group `"Ops"':

           * `"+"', `"-"', `"*"', `"/"', `"^"', `"%%"', `"%/%"'

      * `"&"', `"|"', `"!"'

      * `"=="', `"!="', `"<"', `"<="', `">="', `">"'

      * Group `"Summary"':

           * `all', `any'

      * `sum', `prod'

      * `min', `max'

   SSiimmppllee DDiissppaattcchhiinngg::

        The following builtin functions are generic as well,
        i.e., you can write `methods' for them:

        `[', `[['

        `dimnames<-', `dimnames', `dim<-', `dim'

        `c', `unlist', `as.vector', `is.na', `is.nan'

   RReeffeerreenncceess::

        Appendix A, Classes and Methods of
        Chambers and Hastie (1992). Statistical Models in S;
        Wadsworth & Brooks/Cole.

   SSeeee AAllssoo::

        `methods' for methods of non-Internal generic func-
        tions.

   EExxaammpplleess::

        methods("Math")
        methods("Ops")
        methods("Summary")

        d.fr <- data.frame(x=1:9, y=rnorm(9))
        data.class(1 + d.fr) == "data.frame" ##-- add to d.f. ...

