tableone icon indicating copy to clipboard operation
tableone copied to clipboard

Histograms in Table 1

Open tompollard opened this issue 1 year ago • 11 comments

Not sure how easy this would be to implement, but making a note of this idea: https://twitter.com/DocEd/status/1572603047590916097

why don’t we just have a little histogram for each variable in table 1, in additional to the standard descriptors?

tompollard avatar Sep 21 '22 16:09 tompollard

You mean like this?

image

jraffa avatar Sep 21 '22 19:09 jraffa

Yes! I assume this is https://cran.r-project.org/web/packages/skimr/vignettes/skimr.html?

Looks like it might be possible to do this with Pandas DataFrames, e.g.:

  • https://stackoverflow.com/questions/53468558/adding-image-to-pandas-dataframe
  • https://stackoverflow.com/questions/37365824/pandas-ipython-notebook-include-and-display-an-image-in-a-dataframe

tompollard avatar Sep 21 '22 19:09 tompollard

I think the histograms are represented as text: ▇▅▃▅▇

Seems to be unicode characters: https://www.i2symbol.com/symbols/blocks/x2587-lower-seven-eighths-block-symbol-blocks-symbol-smiley-face

jraffa avatar Sep 21 '22 19:09 jraffa

Yeah, it looks like these would require each column to be mapped to an 1/8th: https://www.compart.com/en/unicode/block/U+2580. Seems doable...

tompollard avatar Sep 21 '22 19:09 tompollard

Just want to let you guys know that skimpy has this implemented, so it should be real easy to learn from 👍

https://github.com/aeturrell/skimpy/blob/9a96f252fca01780425bbbc6d6c62165ce9ccf20/src/skimpy/init.py#L273

MartinBernstorff avatar Apr 14 '23 06:04 MartinBernstorff

Very cool, thanks Martin, we'll check this out! I haven't come across Skimpy before.

tompollard avatar Apr 14 '23 13:04 tompollard

Glad to hear it! I know this isn't on topic, but just want to say I spent 1,5 days implementing something like tableone, found your solution, and deleted all my code. Super happy to find a good, mature solution 👍

MartinBernstorff avatar Apr 17 '23 06:04 MartinBernstorff

@MartinBernstorff thanks for your kind words and I'm glad to hear it has been helpful! We've neglected the package recently so I'm hoping to spend a little time soon making some much needed updates, fixes, etc.

tompollard avatar Apr 17 '23 12:04 tompollard

I'm not clear what to do in the case where a groupby variable is specified. Do we: (1) plot a distribution for each separate group, i.e. if there are 4 groups, add 4 columns each with a separate histogram; or (2) plot a single histogram of the overall distribution of the variable? Any preference @DocEd?

tompollard avatar Apr 24 '23 19:04 tompollard

Tom, i'm delighted that you saw this and picked it up! I imagine an extra histogram column per group, and if there is space, an overall histogram column at the end. a little like histospark works in R (i think a hadley wickham package).

Or if space was at a premium, the summary numbers could be given as normal, and a soft background image of the histogram behind the text within the table cell could be used.

DocEd avatar Apr 25 '23 06:04 DocEd

just seen the rest of this thread. yep, exactly like above.

DocEd avatar Apr 25 '23 06:04 DocEd