R/response.R

Defines functions response predictor_vars.default predictor_vars response_var.default response_var

response_var <- function(model, data) {
  UseMethod("response_var")
}

#' @export
response_var.default <- function(model, data) {
  stats::formula(model)[[2L]]
}

predictor_vars <- function(model, data) {
  UseMethod("predictor_vars")
}

#' @export
predictor_vars.default <- function(model, data) {
  all.vars(stats::formula(model)[[3L]])
}

response <- function(model, data) {
  eval(response_var(model), as.data.frame(data))
}

Try the modelr package in your browser

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

modelr documentation built on March 31, 2023, 5:20 p.m.