Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure extract_stats() and cousins work out of the box with grouped plots #955

Merged
merged 7 commits into from
Jul 27, 2024

Conversation

IndrajeetPatil
Copy link
Owner

@IndrajeetPatil IndrajeetPatil commented Jul 27, 2024

library(ggstatsplot)

p <- grouped_ggpiestats(mtcars, x = cyl, grouping.var = am)
extract_stats(p)
#> [[1]]
#> $subtitle_data
#> # A tibble: 1 × 13
#>   statistic    df p.value method                                   effectsize 
#>       <dbl> <dbl>   <dbl> <chr>                                    <chr>      
#> 1      7.68     2  0.0214 Chi-squared test for given probabilities Pearson's C
#>   estimate conf.level conf.low conf.high conf.method conf.distribution n.obs
#>      <dbl>      <dbl>    <dbl>     <dbl> <chr>       <chr>             <int>
#> 1    0.537       0.95   0.0666     0.725 ncp         chisq                19
#>   expression
#>   <list>    
#> 1 <language>
#> 
#> $caption_data
#> # A tibble: 1 × 4
#>    bf10 prior.scale method                                      expression
#>   <dbl>       <dbl> <chr>                                       <list>    
#> 1  1.15           1 Bayesian one-way contingency table analysis <language>
#> 
#> $pairwise_comparisons_data
#> NULL
#> 
#> $descriptive_data
#> # A tibble: 3 × 4
#>   cyl   counts  perc .label
#>   <fct>  <int> <dbl> <chr> 
#> 1 8         12  63.2 63%   
#> 2 6          4  21.1 21%   
#> 3 4          3  15.8 16%   
#> 
#> $one_sample_data
#> NULL
#> 
#> $tidy_data
#> NULL
#> 
#> $glance_data
#> NULL
#> 
#> attr(,"class")
#> [1] "ggstatsplot_stats" "list"             
#> 
#> [[2]]
#> $subtitle_data
#> # A tibble: 1 × 13
#>   statistic    df p.value method                                   effectsize 
#>       <dbl> <dbl>   <dbl> <chr>                                    <chr>      
#> 1      4.77     2  0.0921 Chi-squared test for given probabilities Pearson's C
#>   estimate conf.level conf.low conf.high conf.method conf.distribution n.obs
#>      <dbl>      <dbl>    <dbl>     <dbl> <chr>       <chr>             <int>
#> 1    0.518       0.95        0     0.741 ncp         chisq                13
#>   expression
#>   <list>    
#> 1 <language>
#> 
#> $caption_data
#> # A tibble: 1 × 4
#>    bf10 prior.scale method                                      expression
#>   <dbl>       <dbl> <chr>                                       <list>    
#> 1 0.434           1 Bayesian one-way contingency table analysis <language>
#> 
#> $pairwise_comparisons_data
#> NULL
#> 
#> $descriptive_data
#> # A tibble: 3 × 4
#>   cyl   counts  perc .label
#>   <fct>  <int> <dbl> <chr> 
#> 1 8          2  15.4 15%   
#> 2 6          3  23.1 23%   
#> 3 4          8  61.5 62%   
#> 
#> $one_sample_data
#> NULL
#> 
#> $tidy_data
#> NULL
#> 
#> $glance_data
#> NULL
#> 
#> attr(,"class")
#> [1] "ggstatsplot_stats" "list"
extract_subtitle(p)
#> [[1]]
#> list(chi["gof"]^2 * "(" * 2 * ")" == "7.68", italic(p) == "0.02", 
#>     widehat(italic("C"))["Pearson"] == "0.54", CI["95%"] ~ "[" * 
#>         "0.07", "0.73" * "]", italic("n")["obs"] == "19")
#> 
#> [[2]]
#> list(chi["gof"]^2 * "(" * 2 * ")" == "4.77", italic(p) == "0.09", 
#>     widehat(italic("C"))["Pearson"] == "0.52", CI["95%"] ~ "[" * 
#>         "0.00", "0.74" * "]", italic("n")["obs"] == "13")
extract_caption(p)
#> [[1]]
#> list(log[e] * (BF["01"]) == "-0.14", italic("a")["Gunel-Dickey"] == 
#>     "1.00")
#> 
#> [[2]]
#> list(log[e] * (BF["01"]) == "0.83", italic("a")["Gunel-Dickey"] == 
#>     "1.00")

Created on 2024-07-27 with reprex v2.1.1

@IndrajeetPatil IndrajeetPatil merged commit 68d299f into main Jul 27, 2024
24 checks passed
@IndrajeetPatil IndrajeetPatil deleted the add-grouped-extract branch July 27, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to export data from grouped extract_stats efficiently? extract_stats from grouped_* plots
1 participant