library(qpToolkit) library(xtable)
Using the internal playground data frame 'pkpdData' we will create a demographics table.
pkpdData = example.pkpdData() options(width = 150) ok = duplicated(pkpdData$id) == F head(pkpdData[ok, ])
So now we have a data frame with patient characteristics. Let's do a summaries on a few of them.
conDataFun1(pkpdData$wt[ok], 3) conDataFun2(pkpdData$wt[ok], 3) catDataFun(pkpdData$sex[ok])
Then there is a wrapper function available called 'tabStats' that intelligently determines the data to be continuous or categorical and applies the appropriate summarization function on basis of that. tabStats uses the summarization function catDataFunc, conDataFun1 and conDataFun2. Here are 2 examples:
tabStats(pkpdData$sex[ok], list(dose = pkpdData$dose[ok])) tabStats(x=pkpdData$wt, BY = list(dose = pkpdData$dose))
Then, the wrapper function 'tabSummarize' takes a formula of the form g ~ x1 + x2 + ... to create a summary of patient characterics x1, x2, ... by grouping variable g. Optionally a blank line is added inbetween each patient characteric summary to improve demographics table legibility. The result is the demographics table.
tabSummarize( formula = dose ~ race + wt + bmi + sex, data = pkpdData[ok, ], digits = 3 )
The grouping variable can be changed ahead of the tabSummarize call to make nicer groupings of course. Automatically, the function full.names is called that swaps shorthand column names into full names (with untis for example). Check full names and expand the function to match the patient characteristics that will be embedded in the demographics table. We will also add an extra blank line to the table.
pkpdData$trt.o = ordered(pkpdData$trt, levels = unique(pkpdData$trt)) demoTable = tabSummarize( formula = trt.o ~ race + wt + bmi + sex, data = pkpdData[ok,], digits = 3, extra.blank.line = TRUE ) print(demoTable)
This 'demoTable' output can be processed for LaTeX use for example.
demoTable.formatted = format( demoTable, formula = trt.o ~ race + wt + bmi + sex ) demoTable.xtable = xtable( demoTable.formatted, caption = "Demographics Table" ) print(demoTable.xtable , sanitize.text.function = identity , include.rownames = F , type = "html" )
And if one has different and/or additional covariates to put into a demogrpahics table, modify the function full.names
in the same spirit as its default:
full.names
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.