GEMINI-Medicine / Rgemini

A custom R package that provides a variety of functions to perform data analyses with GEMINI data
https://gemini-medicine.github.io/Rgemini/
Other
3 stars 0 forks source link

Print html table #102

Open shijiaSMH opened 4 months ago

shijiaSMH commented 4 months ago

Commonly used table printing function for rmarkdowns

printKable = function(df.obj, align.position = "r", scroll = F, width = 7, height = 4, ...){
  coln = dim(df.obj)[2]
  res <- kable(df.obj, "html", align =  rep(align.position, coln), ...) %>%
          kable_styling(full_width = F) %>% 
          scroll_box(width = width, height = height)
  #kable_styling(bootstrap_options = c('striped', 'hover'))
  # if( scroll == T ) {
  #   res <- res %>% scroll_box(width = width, height = height)
  # }
  res
}
loffleraSMH commented 2 months ago

Let's leave this issue for later (I'll remove it from the current sprint). Discussed this with @gemini-wenb yesterday and we think this is a larger issue that requires further discussion. Showing table in html output is one thing, but ideally, we should also allow for table to be exported in an editable format (including table1, which currently isn't possible). Sticking with DT could be one option to allow users to download tables as csv/xlsx files. Alternatively, we could use downloadthis::download_this() (but this needs to be run before creating html table so still wouldn't currently work for table1 output).

gemini-wenb commented 2 months ago

Let's leave this issue for later (I'll remove it from the current sprint). Discussed this with @gemini-wenb yesterday and we think this is a larger issue that requires further discussion. Showing table in html output is one thing, but ideally, we should also allow for table to be exported in an editable format (including table1, which currently isn't possible). Sticking with DT could be one option to allow users to download tables as csv/xlsx files. Alternatively, we could use downloadthis::download_this() (but this needs to be run before creating html table so still wouldn't currently work for table1 output).

And just to provide extra context for why being able to export an editable format is helpful compared to outputting html. When preparing for manuscript / conference posters, authors often need to edit the table based on different needs. Users cannot easily do this with tables in HTML format. They will have the manually copy-paste the table from markdown to make further edits. This gets problematic for large tables. Therefore, providing the options to download tables as csv/xlsx enables easy editing/customization for authors when preparing manuscripts/posters.

shijiaSMH commented 2 months ago

Yes agreed, I like ppl w markdown of csv, pdf, word tabs, presumably csv tabs are most useful for manuscript prep.

Let's discuss this later!