Skip to contents

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)))
#> conflate function for summary
#>  args: x, object.args

purrr::map(
  list(glm.model, lm.model),
  ~ conflated_summary(.,
    lm.correlation = TRUE, glm.correlation = TRUE,
    glm.symbolic.cor = TRUE
  )
)
#> [[1]]
#> 
#> Call:
#> glm(formula = Sepal.Length ~ Sepal.Width, data = iris)
#> 
#> Deviance Residuals: 
#>     Min       1Q   Median       3Q      Max  
#> -1.5561  -0.6333  -0.1120   0.5579   2.2226  
#> 
#> Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)   6.5262     0.4789   13.63   <2e-16 ***
#> Sepal.Width  -0.2234     0.1551   -1.44    0.152    
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> (Dispersion parameter for gaussian family taken to be 0.6807844)
#> 
#>     Null deviance: 102.17  on 149  degrees of freedom
#> Residual deviance: 100.76  on 148  degrees of freedom
#> AIC: 371.99
#> 
#> Number of Fisher Scoring iterations: 2
#> 
#> Correlation of Coefficients:
#>                
#> (Intercept) 1  
#> Sepal.Width B 1
#> attr(,"legend")
#> [1] 0 ‘ ’ 0.3 ‘.’ 0.6 ‘,’ 0.8 ‘+’ 0.9 ‘*’ 0.95 ‘B’ 1
#> 
#> 
#> [[2]]
#> 
#> Call:
#> lm(formula = Sepal.Length ~ Sepal.Width, data = iris)
#> 
#> Residuals:
#>     Min      1Q  Median      3Q     Max 
#> -1.5561 -0.6333 -0.1120  0.5579  2.2226 
#> 
#> Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)   6.5262     0.4789   13.63   <2e-16 ***
#> Sepal.Width  -0.2234     0.1551   -1.44    0.152    
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Residual standard error: 0.8251 on 148 degrees of freedom
#> Multiple R-squared:  0.01382,	Adjusted R-squared:  0.007159 
#> F-statistic: 2.074 on 1 and 148 DF,  p-value: 0.1519
#> 
#> Correlation of Coefficients:
#>             (Intercept)
#> Sepal.Width -0.99      
#> 
#> 

# alternatively, you could supply `correlation` as a default in conflate itself
(conflated_summary <- conflate(summary(x, correlation = TRUE)))
#> conflate function for summary
#>  args: x, correlation = TRUE, object.args

purrr::map(
  list(glm.model, lm.model),
  ~ conflated_summary(., lm.symbolic.cor = TRUE)
)
#> [[1]]
#> 
#> Call:
#> glm(formula = Sepal.Length ~ Sepal.Width, data = iris)
#> 
#> Deviance Residuals: 
#>     Min       1Q   Median       3Q      Max  
#> -1.5561  -0.6333  -0.1120   0.5579   2.2226  
#> 
#> Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)   6.5262     0.4789   13.63   <2e-16 ***
#> Sepal.Width  -0.2234     0.1551   -1.44    0.152    
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> (Dispersion parameter for gaussian family taken to be 0.6807844)
#> 
#>     Null deviance: 102.17  on 149  degrees of freedom
#> Residual deviance: 100.76  on 148  degrees of freedom
#> AIC: 371.99
#> 
#> Number of Fisher Scoring iterations: 2
#> 
#> Correlation of Coefficients:
#>             (Intercept)
#> Sepal.Width -0.99      
#> 
#> 
#> [[2]]
#> 
#> Call:
#> lm(formula = Sepal.Length ~ Sepal.Width, data = iris)
#> 
#> Residuals:
#>     Min      1Q  Median      3Q     Max 
#> -1.5561 -0.6333 -0.1120  0.5579  2.2226 
#> 
#> Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)   6.5262     0.4789   13.63   <2e-16 ***
#> Sepal.Width  -0.2234     0.1551   -1.44    0.152    
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Residual standard error: 0.8251 on 148 degrees of freedom
#> Multiple R-squared:  0.01382,	Adjusted R-squared:  0.007159 
#> F-statistic: 2.074 on 1 and 148 DF,  p-value: 0.1519
#> 
#> Correlation of Coefficients:
#>                
#> (Intercept) 1  
#> Sepal.Width B 1
#> attr(,"legend")
#> [1] 0 ‘ ’ 0.3 ‘.’ 0.6 ‘,’ 0.8 ‘+’ 0.9 ‘*’ 0.95 ‘B’ 1
#> 
#>