Add p-value for means comparison table (tab_stat_mean_sd_n)

154 Views Asked by At

Do you happen to know how to add a column with p-value when comparing means using tab_stat_mean_ds_n() from the expss package? The tab_significance_options() offer a lot of modifications but I can't find anything to add just extra column with p-values.

Thanks

1

There are 1 best solutions below

1
On

I am an author of the expss package. Sorry, but currently there is no such functionality as adding column with p-value. There are a lot of cases when column significant differs from many other columns. See simple example below. I don't know how to add columns with p-value in a sensible way in the such circumstances. If you can provide nice table examples with multiple p-value columns I will consider to add such option in the future version of the package.

library(expss)
data(mtcars)

mtcars = apply_labels(mtcars,
                      mpg = "Miles/(US) gallon",
                      cyl = "Number of cylinders"
)

mtcars %>% 
    tab_cells(mpg) %>% 
    tab_cols(cyl) %>% 
    tab_stat_mean_sd_n() %>% 
    tab_pivot() %>% 
    significance_means()

# |                   |              | Number of cylinders |        |      |
# |                   |              |                   4 |      6 |    8 |
# |                   |              |                   A |      B |    C |
# | ----------------- | ------------ | ------------------- | ------ | ---- |
# | Miles/(US) gallon |         Mean |            26.7 B C | 19.7 C | 15.1 |
# |                   |    Std. dev. |             4.5     |  1.5   |  2.6 |
# |                   | Unw. valid N |            11.0     |  7.0   | 14.0 |