R/case.R

Defines functions case

case <- function(...) {
  
  dots <- list(...)
  for (dot in dots) {
    
    if (!inherits(dot, "formula"))
      return(dot)
    
    else if (length(dot) == 2) {
      expr <- dot[[2]]
      return(eval(expr, envir = environment(dot)))
    }
    
    else {
      
      cond <- dot[[2]]
      expr <- dot[[3]]
      if (eval(cond, envir = environment(dot)))
        return(eval(expr, envir = environment(dot)))
      
    }
  }
  
  NULL
  
}

Try the reticulate package in your browser

Any scripts or data that you put into this service are public.

reticulate documentation built on Sept. 11, 2024, 8:31 p.m.