Learn R Programming

fda (version 2.3.2)

CRAN: Test if running as CRAN

Description

This function allows package developers to run tests themselves that should not run on CRAN or with "R CMD check --as-cran" because of compute time constraints with CRAN tests.

Usage

CRAN(x='_R_CHECK_TIMINGS_')

Arguments

x
name of an environmental variable to check.

Value

  • a logical scalar

Details

x. <- Sys.getenv(x) xl <- as.logical(x.)

return((!is.na(xl)) || xl)

This returns FALSE either if the environmental variable is not found or it is not TRUE.

Duncan Murdoch noted that the following variables are set by "--as-cran": _R_CHECK_TIMINGS_, _R_CHECK_INSTALL_DEPENDS_, _R_CHECK_NO_RECOMMENDED_, and _R_SHLIB_BUILD_OBJECTS_SYMBOL_TABLES_. For this purpose, he suggested we use the first.

Examples

Run this code
cran <- CRAN()
str(cran)
print(cran)
stop()

if(CRAN()){
  stop('CRAN')
} else {
  stop('NOT CRAN')
}

Run the code above in your browser using DataLab