TysonStanley / furniture

The furniture R package contains table1 for publication-ready simple and stratified descriptive statistics, tableC for publication-ready correlation matrixes, and other tables #rstats
49 stars 7 forks source link

Additional summary statistics to table1 #14

Closed apatel9437 closed 6 years ago

apatel9437 commented 6 years ago

Are there any plans to include additional summary statistics to table1? For example, the ability to include percentiles, minimum and maximum values etc. The other question I have is if it is possible to include the mean and median together in the same table (arguments FUN and FUN2). I tried to do this but after looking at the source code, it does not look like it is currently set up to handle that particular scenario.

TysonStanley commented 6 years ago

Great question. I've considered doing this where the mean would be on one line and median would be on another. However, this likely won't be integrated in the near future. The current way is to use the FUN arg. For example, you could do something like this:

mean_median_fun <- function(x){
  paste0("M: ", round(mean(x, na.rm = TRUE), 2), ", Med: ", median(x, na.rm = TRUE))
}

nhanes_2010 %>%
  dplyr::group_by(gender) %>%
  table1(vig_active,
         FUN = mean_median_fun)

My main problem with this approach is that the table gets wide, very quickly. That is why I would like to have different statistics on different rows but that will take some time to implement, given my other obligations.