[R] conditional function definition?

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Sat Sep 20 16:07:59 CEST 2003


Hi Folks,

What is the best way to avoid a function being read in
anew (and masking an exiting function) when a definition
of it has already been established in R?

Reason: Fernando Tusell and I are working up Schafer's 'CAT'
for R (basically done now, just needs some cosmetic tidying up).

This uses a function 'slice.index', present in S but not in
the versions of R we were working with at the time. So we put
in a definition (copied from R-help ... ).

However, it seems that slice.index is now in "base" in latest
versions of R. So it would seem a bit silly to read it in anew.
Nevertheless, probably we should keep it in for the sake of people
still using older versions of R who would not have it.

So what's the best method to do

if( some test for function slice.index absent ) {
  slice.index<-function(....){....}
}

??

Thanks,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 20-Sep-03                                       Time: 15:07:59
------------------------------ XFMail ------------------------------




More information about the R-help mailing list