"ifdef"'ing R/S code: if(is.R())

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Fri, 26 Dec 1997 16:27:14 +0100

>>>>> "DougB" == Douglas Bates <bates@stat.wisc.edu> writes:

    DougB> I should have saved the messages about this but I didn't.  Can
    DougB> someone remind me of what function or object to check from
    DougB> within a function to determine if you are running R?  I need to
    DougB> make some changes in code according to whether I am running it
    DougB> under R or under S and I would prefer to keep one source tree.

##>>>>>> This works in all of <<<<<
##-- S  (including "S version 4", (beta))
##-- R
##-- S-plus

is.R <- function() { ## returns  'TRUE'  iff we are using 'R'
  exists("version") && !is.null(vl <- version$language) && vl == "R"

#- some may want:
is.S <- function() !is.R()

I think I should add this function to the R base,
or do we need a new package  "Scompatibility"  which could server other
things as well? 

I for one, am having more and more need for an "Rcompatibility" package in

r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch