1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
enums <- new.env()
.onAttach <- function(libname, pkgname){
enums$type <- enums_types()
enums$depth <- enums_depth()
}
enum_label <- function(type, id){
kv <- enums[[type]]
recoder(id, from = kv$key, to = kv$value)
}
enum_id <- function(type, label){
kv <- enums[[type]]
recoder(label, from = kv$value, to = kv$key)
}
.onLoad <- function(libname, pkgname){
if(is_check()){
set_num_threads(2)
}
}
is_macos <- function(){
grepl("darwin", R.Version()$platform)
}
is_iterm2 <- function(){
identical(Sys.getenv('TERM_PROGRAM'), 'iTerm.app')
}
is_check <- function(){
grepl('opencv.Rcheck', getwd(), fixed = TRUE)
}
is_mojave <- function(){
ver <- utils::tail(strsplit(utils::sessionInfo()$running, ' ')[[1]], 1)
as.numeric_version(ver) >= "10.14"
}
is_rstudio <- function(){
Sys.getenv('RSTUDIO') == "1"
}
|