I'm trying to assemble a title for a histogram plot in R. The title I want derives from two sources, first a vector (death.cause) specifying, er, cause-of-death, and second a field from a data.frame, into which I index using a list, deathratecols, to get at the field.
> death.cause
> [[1]] [1] "Heart Attack"
>
> [[2]] [1] "Heart Failure"
>
> [[3]] [1] "Pneumonia"
> deathratecols
> [1] 11 17 23
I want to assemble title like: Heart Attack (x-bar = 7.63763) , where x-bar is the mean of the data column. I can get the two parts to work separately as below.
> main=substitute(x, list(x=death.cause[[i]]) )) # gives title "Heart Attack"
> main=substitute(bar(X)==k, list(k=mean(outcome[, deathratecols[i] ], na.rm=TRUE ) )) # gives title x-bar=7.63763
But my efforts to put the two together using paste() have failed.
? someone point out the error of my ways please