Skip to content

Parametrizing heading in tables package

2 messages · Jean-Louis Abitbol, Duncan Murdoch

#
Dear R-Helpers,

I am using the (great) tables package in a function this way:

parplot <- function (x){
test <- pkqps[pkqps$estimate == x,]
####
#some plotting 
#####
tab <- tabular((Heading("Analyte")*(analyte) * Heading(Site)* (fsite)) 
         ~ (n=1)+ Justify(c)*Heading(substitute(test$estimate[1]))
               *(result)*(Mean + Median + Min + Max + CV)
                   * Format(digits = 1), data = test)
html(tab, file = paste(qpar$param[1],"stat",".html", sep=""))
}
parplot("Cmax")
parplot("AUClast")
etc...

I am trying to parametrize the heading in tabular with
"Heading(substitute(test$estimate[1]))".
test$estimate[1] is a character variate which is the name I want to
appear in the heading (ie Cmax for example in the first call of the
function.

This does not work and produces just "substitute(test$estimate[1])" in
the heading. 

I Have also tried quote() without success.

Any advice on how to do this will be much appreciated,

Best wishes, JL
#
On 20/11/2013 9:17 AM, Jean-Louis Abitbol wrote:
I would use substitute() on the whole formula.  For example,

a <- "New heading"
x <- rnorm(100)

tabular( substitute( Heading( head )*x ~ mean, list(head = a) ) )

Duncan Murdoch