Skip to contents

Lays a smart_cor() result out as a one-row tibble in the manner of the broom package, so results drop straight into a dplyr pipeline.

Usage

# S3 method for class 'smartcor'
tidy(x, ...)

Arguments

x

A smartcor object.

...

Ignored.

Value

A one-row tibble::tibble() with columns covering identifiers (var_x, var_y, x_type, y_type), the point estimate, the chosen method (method, method_label, rationale), inference details (statistic, p.value, p_method, null_hypothesis, p_interpretation, ci_lower, ci_upper, conf_level, ci_method, ci_source), and sample sizes (n, n_complete).

Examples

csv = system.file("extdata", "gss_2024_casestudy.csv", package = "smartcor")
gss = read.csv(csv)
res = smart_cor(gss$coninc, gss$age, verbose = FALSE)
tidy(res)
#> # A tibble: 1 × 20
#>   var_x     var_y x_type y_type estimate method method_label rationale statistic
#>   <chr>     <chr> <chr>  <chr>     <dbl> <chr>  <chr>        <chr>         <dbl>
#> 1 gss$coni… gss$… conti… count    0.0192 pears… Pearson Cor… One vari…      1.05
#> # ℹ 11 more variables: p.value <dbl>, p_method <chr>, null_hypothesis <chr>,
#> #   p_interpretation <chr>, ci_lower <dbl>, ci_upper <dbl>, conf_level <dbl>,
#> #   ci_method <chr>, ci_source <chr>, n <int>, n_complete <int>