is.R                  package:base                  R Documentation

_A_r_e _w_e _u_s_i_n_g _R, _r_a_t_h_e_r _t_h_a_n _S?

_D_e_s_c_r_i_p_t_i_o_n:

     Test if running under R.

_U_s_a_g_e:

     is.R()

_D_e_t_a_i_l_s:

     The function has been written such as to correctly run in all
     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_
      '}'

_V_a_l_u_e:

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

_S_e_e _A_l_s_o:

     'R.version', 'system'.

_E_x_a_m_p_l_e_s:

     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]

