R/addons-boot.R

Defines functions append_transpilers_for_boot

# boot::boot(...) =>
#
# local({
#   cl <- future::makeClusterFuture(<future arguments>)
#   boot::boot(..., parallel = "snow", ncpus = 2L, cl = cl)
# })
#
append_transpilers_for_boot <- function() {
  if (getRversion() < "4.4.0") {
    stop(sprintf("You are running R %s, but futurization of 'boot' functions requires R (>= 4.4.0)", getRversion()))
  }

  transpiler <- make_futurize_for_makeClusterFuture(args = list(
    parallel = "snow",
    ncpus = 2L,   ## only used for test ncpus > 1
    cl = quote(cl)
  ))

  transpilers <- make_package_transpilers("boot", FUN = function(fcn, name) {
    if ("parallel" %in% names(formals(fcn))) {
      list(
        label = sprintf("boot::%s() ~> boot::%s(..., parallel = TRUE)",  name, name),
        transpiler = transpiler
      )
    }
  })

  append_transpilers("futurize::add-on", transpilers)

  ## Return required packages
  c("boot", "future")
}

Try the futurize package in your browser

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

futurize documentation built on March 19, 2026, 1:07 a.m.