[R] summary in Hmisc and Latex
Marc Schwartz
marc_schwartz at me.com
Tue Aug 31 21:44:16 CEST 2010
On Aug 31, 2010, at 12:42 PM, moleps wrote:
> Dear all,
>
> With the latest update of Hmisc I no longer have any problems with latex. However using the ctable option produces latex code that at least on both the miktex distribution at work and mactex distribution at home refuses to run due to an extra blank line inserted between the multicolumn lines in the latex code... It runs fine if the line is deleted or if the ctable option is left out. Does this apply to other people as well?
>
> Regards,
> //M
>
>
>
>
>
> library(Hmisc)
>
> options(digits=3)
> set.seed(173)
> sex<- factor(sample(c("m","f"), 500, rep=TRUE))
> age<- rnorm(500, 50, 5)
> treatment<- factor(sample(c("Drug","Placebo"), 500, rep=TRUE))
> symp<- c('Headache','Stomach Ache','Hangnail',
> 'Muscle Ache','Depressed')
> symptom1<- sample(symp, 500,TRUE)
> symptom2<- sample(symp, 500,TRUE)
> symptom3<- sample(symp, 500,TRUE)
> Symptoms<- mChoice(symptom1, symptom2, symptom3, label='Primary Symptoms')
> table (Symptoms)
> table(symptom1,symptom2)
> f<- summary(treatment ~ age + sex + Symptoms, method="reverse", test=TRUE)
> latex(f,file="")
> latex(f,file="",ctable=T)
With ctable, you cannot have any blank lines within the table's definition, as compared to a normal tabular environment. This is because ctable is a command, as opposed to an environment. That is, you use \ctable[...]{...} as opposed to \begin{tabular} ... \end{tabular}.
I recall coming across that issue when implementing my own reporting tools for use in Sweave, where I default to the use of ctable, as I prefer the look. One approach instead of removing the blank lines, is to just comment them out (eg. using a '%' character).
I am cc'ing Frank here, in case he is not aware of this, albeit I presume that he is and that this behavior is a buglet.
HTH,
Marc Schwartz
More information about the R-help
mailing list