is.R {base}R Documentation

Are we using R, rather than S?

Description

Test if running under R.

Usage

is.R()

Details

The function was been written ca 2007 such as to correctly run in all historical versions of R, S and S-PLUS. In order for code to be runnable in both R and S dialects previous to S-PLUS 8.0, your code must either define is.R or use it as

if (exists("is.R") && is.function(is.R) && is.R()) {
## R-specific code
} else {
## S-version of code
}

(and this will only work if all of the code is parseable under all possible dialects).

Note that it does not actually demonstrate that it is being run under R, rather that is not being run under a long-obsolete version of S or S-PLUS. It will be deprecated in future versions of R.

Value

is.R returns TRUE if we are using R and FALSE otherwise.

See Also

R.version, system.

Examples

x <- stats::runif(20); small <- x < 0.4
## In the early years of R, 'which()' only existed in R:
if(is.R()) which(small) else seq(along = small)[small]
## but it would have been better to test if 'which' existed.

[Package base version 4.3.2 Index]