[R] conditional function definition?

kjetil brinchmann halvorsen kjetil at entelnet.bo
Sat Sep 20 17:30:31 CEST 2003


On 20 Sep 2003 at 15:07, Ted Harding wrote:

What about 

> exists("slice.index")
[1] TRUE

Kjetil Halvorsen

> 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 ------------------------------
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help




More information about the R-help mailing list