conflate: Combine generic method interfaces

View source: R/conflate.R

conflateR Documentation

Combine generic method interfaces

Description

conflate combines methods for any S3 standard generic allowing arguments of various methods to be specified in a single function that it returns.

Usage

conflate(generic_spec)

Arguments

generic_spec

[call] Generic function as applied to arguments shared between all methods to be combined.

Value

Function with additional class conflate with arguments being

conflate_func(generic_spec_args, ..., evaluate = TRUE)

Where ... specifies additional arguments to be supplied in the form object_class.arg. The evaluate argument is useful for debugging purposes.

Combining Methods

The generic_spec argument is the generic function as applied to shared arguments between methods that are to be combined. Once this is decided, all additional arguments passed to the generated function need to be of the form object_class.arg that are arguments unique to each method as dispatched for each object class.

See Also

Other function assemblers: convoke()

Examples

# first construct two models
glm.model <- glm(Sepal.Length ~ Sepal.Width, data = iris)
lm.model <- lm(Sepal.Length ~ Sepal.Width, data = iris)

# create summary with extra object arguments using `conflate`
(conflated_summary <- conflate(summary(x)))

purrr::map(
  list(glm.model, lm.model),
  ~ conflated_summary(.,
    lm.correlation = TRUE, glm.correlation = TRUE,
    glm.symbolic.cor = TRUE
  )
)

# alternatively, you could supply `correlation` as a default in conflate itself
(conflated_summary <- conflate(summary(x, correlation = TRUE)))

purrr::map(
  list(glm.model, lm.model),
  ~ conflated_summary(., lm.symbolic.cor = TRUE)
)

TerseTears/tyecon documentation built on July 7, 2022, 2:45 p.m.