Skip to contents

Tidy output from grouped analysis of any function that has data argument in its function call

Usage

grouped_tidy(data, grouping.vars, ..f, ..., tidy.args = list())

Arguments

data

Dataframe (or tibble) from which variables are to be taken.

grouping.vars

Grouping variables.

..f

A function, or function name as a string.

...

<dynamic> Arguments for .fn.

tidy.args

A list of arguments to be used in the relevant S3 method.

Value

A tibble::tibble() with information about model components.

See also

Examples

set.seed(123)
library(dplyr)

# linear mixed effects model
grouped_tidy(
  data = mutate(MASS::Aids2, interval = death - diag),
  grouping.vars = sex,
  ..f = lme4::lmer,
  formula = interval ~ age + (1 | status),
  control = lme4::lmerControl(optimizer = "bobyqa"),
  tidy.args = list(conf.int = TRUE, conf.level = 0.99)
)
#> # A tibble: 8 × 9
#>   sex   effect   group    term           estim…¹ std.e…² stati…³ conf.…⁴ conf.…⁵
#>   <fct> <chr>    <chr>    <chr>            <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#> 1 F     fixed    NA       (Intercept)     623.   161.       3.88  209.   1037.  
#> 2 F     fixed    NA       age              -4.34   2.61    -1.66  -11.1     2.38
#> 3 F     ran_pars status   sd__(Intercep…  169.    NA       NA      NA      NA   
#> 4 F     ran_pars Residual sd__Observati…  415.    NA       NA      NA      NA   
#> 5 M     fixed    NA       (Intercept)     553.    62.5      8.84  392.    714.  
#> 6 M     fixed    NA       age              -3.60   0.696   -5.17   -5.39   -1.80
#> 7 M     ran_pars status   sd__(Intercep…   79.8   NA       NA      NA      NA   
#> 8 M     ran_pars Residual sd__Observati…  355.    NA       NA      NA      NA   
#> # … with abbreviated variable names ¹​estimate, ²​std.error, ³​statistic,
#> #   ⁴​conf.low, ⁵​conf.high