[R] How would you program an Adverse Events statistical table using R code?

Robert Wilkins irishhacker at gmail.com
Sat Feb 25 01:13:10 CET 2012


A graph != A table.
I'm talking about a page full of summary statistics and advanced
statistics, with lots of cross categories on the top and left margin
of the table, as opposed to a visual display with x-axis and y-axis,
which is totally different.

(An example of how this is done in another language is available  at
http://fivetimesfaster.blogspot.com )

For an AE table, you have an N and % column for every treatment group,
and for all patients combined. On the right side, a categorical
p-value (chi-sq or Fisher's) for every preferred term (every row!
forget multiple testing issues, this is what the boss is asking
for(it's ad-hoc safety analysis))
There's a row for grand total N for each group.
A row for N and % of patients with any event (regardless of body
system and preferred term)
For each body system, there's a section of rows that include:
  A row for N and % of patients with any event (this body system)
  A row for N and % of patients who do NOT have an event( this body system)
  And , of course, within body system, a row for each preferred term
(again N and % for each group , and also the p-value)

Body system and preferred term are, of course broad medical category
and specific medical category.


In the Pharma industry, they use the SAS programming language. Each
table often needs several hundred lines of code. Essentially it's a
combination of analysis and (visual)-reporting mixed together, with
some prerequisite data transformation. (And yes, with this new
language, it can be done in under 20 lines of code).

I have not seen people discuss attempts to do such things with the R
programming language, and how successful such attempts have been. How
hard is it, how much code is it?

In general, we are talking about a variety of complex,
somewhat-nonhomogeneous statistical tables with a variety of different
row sections and row categories, and different column sections and
column categories, and a mixture of summary statistics and advanced
statistics (p-value , least square mean, etc), and sometimes
statistics from different statistical procedures on the same page.

Robert Wilkins



More information about the R-help mailing list