[R] adding a method to the dist function

Martin Maechler maechler at stat.math.ethz.ch
Mon May 3 12:34:51 CEST 2004


>>>>> "Giampiero" == Giampiero Salvi <giampi at speech.kth.se>
>>>>>     on Mon, 3 May 2004 11:50:38 +0200 (CEST) writes:

    Giampiero> I'd like to add the Bhattacharyya method to the
    Giampiero> dist function.  What is the best way to do this?
    Giampiero> I'm using R 1.9.0 and I was looking for the code
    Giampiero> that defines the already existing distances, but
    Giampiero> I didn't manage. As far as I understand, dist is
    Giampiero> defined in mva that is part of the stats package
    Giampiero> now, but where is the code?

All the standard R packages (such as "stats") are in
 <Rsource>/src/library/
and look very much like usual R packages,
[with the exception of the 'base' package that is very special]

I.e, in

    <Rsource>/src/library/stats/R/dist.R
    <Rsource>/src/library/stats/man/dist.Rd
    <Rsource>/src/library/stats/src/distance.c

are the R source, docu, and C code, respectively.
Where you can e.g. take and unpack 
      ftp://stat.ethz.ch/Software/R/R-devel.tar.gz
such that the above '<Rsource>' will be  'R-devel' for you.

If you do this, please consider contributing the three changed
files back to the R project!


    Giampiero> Thank you very much,
    Giampiero> Giampiero

you're welcome,
Martin




More information about the R-help mailing list