Home

The union of all files from all check-ins in the top-level directory


Design notes

These are some names I played with:

aod :: arangment of data yat :: yet another table drc :: data in rows and columns rcd :: rows and columns data mft :: my friend's table mftf :: my friend's table functions rcd :: rows and columns data tbl :: table tay :: tables able :: a short table tapi :: table API apit :: API for tables yast :: yet another summary table yadt :: yet another descriptive table yalmt :: yet another lm table yalmert :: yet another lmer table dst :: descriptive statistics table

But then I realized there can't be one function to do everything. For example, the code to generate a table of descriptive statistics would be quite different from the code to extract coef(summary(fit)) and put it into a table.

So this is what I have

  • tods or toss is a function to create a table of descriptive statisics
  • tolm creates a table from an lm model
  • etc.

Table of summary statistics

The formula interface would look like this:

toss(margin(group) + group + p(group) ~ mediqr(age) + npc(sex), data = dat)

The functions mediqr (for median and IQR) and npc (for number and percent) are functions that calculate the desired summaries. These could take up multiple rows in the table like this:

Total Group A Group B P-value
Age, median (IQR)
Sex, n (%)
Men
Women

There can be some formating in functions like mediqr with the first argument being something like didits.

mediqr

This function and others like it have a fmt argument that is similar in spirit to the (first) fmt argument of sprintf.

mediqr(age, fmt = "%f (%f, %f)")

The fmt string could be extended to encode stying issues like alignment and border.

I guess these summary functions can return an object of descriptive_statistic (or shorter name) and since the object has an fmt element the print method can look at this element?

Table headers and caption

I can imagine something like this:

tods(group ~ mediqr(age, th = "Age, years"), data = dat, caption = "Summary table", header = ???

I don't know good syntax for the column headers. In HTML5 these are <tr> tags with a scope (I think).

What about this:

header = c(tr(th("Name", rowspan = 2), th("ID", rowspan = 2), th("Membership", colspan = 2), th("Balance", rowspan = 2)), tr(th("Joined"), th("Cancelled")))