R/with.mitml.list.R

Defines functions with.mitml.list

Documented in with.mitml.list

with.mitml.list <- function(data, expr, include.data = FALSE, ...){
# evaluates an expression for a list of data sets

  expr <- substitute(expr)
  pf <- parent.frame()

  # check include.data argument
  if(is.character(include.data)){
    name.data <- include.data
    include.data <- TRUE
  }else{
    name.data <- "data"
  }

  out <- if(include.data){

    lapply(data, function(d, expr){
      expr[[name.data]] <- substitute(d)
      eval(expr, parent.frame())
    }, expr = expr)

  }else{

    lapply(data, function(d, expr, pf) eval(expr, d, pf), expr = expr, pf = pf)

  }

  class(out) <- c("mitml.result", "list")
  return(out)

}

Try the mitml package in your browser

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

mitml documentation built on Jan. 6, 2023, 5:17 p.m.