[R] Variance generic function:

Martin Maechler maechler at stat.math.ethz.ch
Thu Oct 30 11:51:10 CET 2008


>>>>> "HLS" == Han Lin Shang <hanlin.shang at gmail.com>
>>>>>     on Sun, 26 Oct 2008 18:02:20 +1100 writes:

    HLS> Hi Dear R-users: I am building a R package and would
    HLS> like to create a generic variance function. Here is how
    HLS> I did

    HLS> var=function(x,...)  { UseMethod("var") }

    HLS> I wrote a Rd file, put the R code in the right
    HLS> directory, and named var, var.default in the
    HLS> namespace. However, once I typed rcmd check , it gave
    HLS> me an error in S3-generic step.  However, that error
    HLS> would not occur for mean and median generic
    HLS> functions. Any suggestion is highly appreciated.

There's not much we can say, given the very vague description.
Just to make sure:
You are not talking about the simple message
(a *message* or ('notice') not an "error" !)

  > Attaching package: '<yourPackage>'
  >
  >
  > 	The following object(s) are masked from package:stats :
  >
  > 	 var 

Are you?

In any case, package 'circular' is one CRAN package example that
uses a NAMESPACE and redefines var(), defines var.default() etc.

So you can take that as your example.

Regards,
Martin Maechler



More information about the R-help mailing list