0

Below is my code for calculating some descriptive stats. Is it somehow possible to add IQR and/or quartiles into this? Or is there a better way to do this kind of statistics for multiple variables in my latent data frame when using another variable 'Location' to separate and have a nice table for all locations at once? Thanks a lot.

library(expss)

CenAll %>% 
  tab_cells(Maintenance, Organization, SocialConnection, Entertainment,
            Uniqueness, Colours, Sound, Irritated, Safe,
            Restricted, Threatened, Stimulated, CaredFor, 
            Rejected, Calm, Free, Anxious, Green,
            Gray, Water) %>%
  tab_cols(total(label = "All| |"), Location) %>% 
  tab_stat_fun(Mean = w_mean, "Median" = w_median, "Std. dev." = w_sd, "Valid N" = w_n, method = list) %>%
  tab_pivot()
UseR10085
  • 7,120
  • 3
  • 24
  • 54

1 Answers1

0

You can easily add IQR in the same way as other functions:

library(expss)

CenAll %>% 
  tab_cells(Maintenance, Organization, SocialConnection, Entertainment,
            Uniqueness, Colours, Sound, Irritated, Safe,
            Restricted, Threatened, Stimulated, CaredFor, 
            Rejected, Calm, Free, Anxious, Green,
            Gray, Water) %>%
  tab_cols(total(label = "All| |"), Location) %>% 
  tab_stat_fun(Mean = w_mean, "Median" = w_median, IQR = IQR, "Std. dev." = w_sd, "Valid N" = w_n, method = list) %>%
  tab_pivot()
Gregory Demin
  • 4,596
  • 2
  • 20
  • 20