R/label_OP.R

Defines functions `%label%`

#' Specify label for a future assignment
#'
#' @usage fassignment \%label\% label
#'
#' @param fassignment The future assignment, e.g.
#'        `x %<-% { expr }`.
#' @inheritParams future
#'
#' @export
`%label%` <- function(fassignment, label) {
  fassignment <- substitute(fassignment)
  envir <- parent.frame(1)

  ## Temporarily set 'label' argument
  args <- getOption("future.disposable", list())
  args["label"] <- list(label)
  options(future.disposable = args)
  on.exit(options(future.disposable = NULL))
  
  eval(fassignment, envir = envir, enclos = baseenv())
}

Try the future package in your browser

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

future documentation built on Sept. 11, 2024, 7:35 p.m.