R/define_data_for_res_order.R

Defines functions define_data_for_res_order

# Calculate res_order, if that requires columns, which should refer to data
# argument rather than X matrix formed by lm(). This is done by sneaking a
# "data" element to distfreereg.function via the control argument.
define_data_for_res_order <- function(test_mean, data, ordering, override, control){
  if(is.null(override[["res_order"]]) && (identical(ordering, "natural") || is.list(ordering))){
    if(is.null(control)){
      control <- list()
    } else {
      if(!is.list(control)) stop("'control' must be NULL or a list")
    }
    data_for_ordering <- data
    data_for_ordering[[get_response(test_mean)]] <- NULL
    data_for_ordering[["(weights)"]] <- NULL
    control[["data"]] <- data_for_ordering
  }
  return(control)
}

Try the distfreereg package in your browser

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

distfreereg documentation built on April 4, 2025, 12:30 a.m.