Skip to contents

Create a new Method.

Usage

create_method(.method_fun, .name = NULL, ...)

Arguments

.method_fun

The method function.

.name

(Optional) The name of the Method.

...

Arguments to pass into .method_fun().

Value

A new instance of Method.

Examples

# create an example Method function
lm_fun <- function(X, y, cols = c("X1", "X2")) {
  lm_fit <- lm(y ~ X)
  pvals <- summary(lm_fit)$coefficients[cols, "Pr(>|t|)"] %>%
    setNames(paste(names(.), "p-value"))
  return(pvals)
}

# create Method with default arguments
lm_method <- create_method(.method_fun = lm_fun, .name = "OLS")

# create Method with non-default arguments
lm_method_x1 <- create_method(.method_fun = lm_fun, .name = "OLS X1",
                              # additional named parameters to pass to lm_fun()
                              cols = "X1")