tompollard / tableone

Create "Table 1" for research papers in Python
https://pypi.python.org/pypi/tableone/
MIT License
164 stars 41 forks source link

Generate legend or summary text to accompany the table #26

Open tompollard opened 6 years ago

tompollard commented 6 years ago

Consider generating a legend populated with details of the table. e.g. this might include:

jraffa commented 6 years ago

So, what I was think of was explainr. https://github.com/hilaryparker/explainr

ptest <- prop.test(x = 500, n = 1008)
explain(ptest)

Yields text generated from a template:

This was a one-sample proportion test of the null hypothesis that the true population proportion is equal to 0.5. Using a significance level of 0.05, we do not reject the null hypothesis, and cannot conclude that true population proportion is different than 0.5. The observed sample proportion is 0.496031746031746 (500 events out of a total sample size of 1,008).

The confidence interval for the true population proportion is (0.464746, 0.5273481). This interval will contain the true population proportion 95 times out of 100.

The p-value for this test is 0.8254979. This, formally, is defined as the probability -- if the null hypothesis is true -- of observing a sample proportion that is as or more extreme than the sample proportion from this data set. In this case, this is the probability -- if the true population proportion is 0.5 -- of observing a sample proportion that is greater than 0.503968253968254 or less than 0.4960317460

TBH, this is probably a separate package

tompollard commented 6 years ago

the explain() functionality is something that could be nice to implement. explain(var) could be a method called on the tableone object to give a more human readable explanation of the data for this particular variable (e.g. tableone.explain(age)).