R/fit.R

Defines functions fit.wflist

Documented in fit.wflist

#' @importFrom generics fit
#' @export
generics::fit

#' Fit a list of models
#'
#' @description
#' Fits a list of workflows to a provided `data.frame`.
#'
#' @param workflows A named list of `workflow` objects created by `wf_list()`.
#' @param data A `data.frame` containing data on which to fit the workflows.
#'
#' @return A named list of fitted `workflow` objects.
#' @export
fit.wflist <- function(workflows, data) {
  out <- purrr::map(workflows, ~generics::fit(.x, data))

  class(out) <- c("wflist", class(out))

  return(out)
}
szego/cassoulet documentation built on Dec. 31, 2020, 7:40 a.m.