[R] Latex problem in Hmisc (3.8-1) and Mac Os X with R 2.11.1

moleps islon moleps2 at gmail.com
Fri Jun 18 07:32:52 CEST 2010

Dear all,

I did post this more or less identical mail in a follow up to another
question I posted, but under another heading. I try again, but now
under the correct header.

upon running this code (from the Hmisc library-latex function) I
believe the call to summary.formula is allright and produces wonderful
tables, but the latex command results in a correct formatted table but
where all the numbers and the test columns are wrong. I've pasted in
both the R code and the resulting latex code annotated with comments
from the run. Does the same code produce correct cell-entries in other
installation ?



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)
f <- summary(treatment ~ age + sex + Symptoms, method="reverse", test=TRUE)
g <- summary(treatment ~ age + sex + symptom1, method="reverse", test=TRUE)


> latex(g,file="")
% latex.default(cstats, title = title, caption = caption, rowlabel =
rowlabel,      col.just = col.just, numeric.dollar = FALSE,
insert.bottom = legend,      rowname = lab, dcolumn = dcolumn,
extracolheads = extracolheads,      extracolsize = Nsize, ...)
 \caption{Descriptive Statistics by treatment\label{g}}

$N=263$}}&\multicolumn{1}{c}{{\scriptsize $N=237$}}&\tabularnewline


\noindent {\scriptsize $a$\ }{$b$\ }{\scriptsize $c$\ } represent the
lower quartile $a$, the median $b$, and the upper quartile $c$\ for
continuous variables.\\Numbers after percents are
frequencies.\\\indent Tests used:\\\textsuperscript{\normalfont
1}Wilcoxon test; \textsuperscript{\normalfont 2}Pearson test

###Then I did another example from Harrell´s "statistical tables and plots...."


# Variables in prostate had units in ( ) inside variable labels. Move
# these units of measurements to separate units attributes
# wt is an exception. It has ( ) in its label but this does not denote units
# Also make hg have a legal R plotmath expression
prostate<-upData(prostate, moveUnits=TRUE,units=c(wt="",
hg="g/100*ml"),labels=c(wt="Weight Index = wt(kg)-ht(cm)+200"))

stage<- factor(stage, 3:4, c("Stage 3","Stage 4"))
overall=TRUE, test=TRUE)
w<-latex(s6, size="smaller[3]", outer.size="smaller",
Nsize="smaller",long=TRUE, prmsd=TRUE,
msdsize="smaller",middle.bold=TRUE, ctable=TRUE)

##This refused to run ( as long as the ctable=T was included), but without it

latex (s6)

##I do get a nicely formated table, but again the numbers are all wrong... Also

##latex(s6, long=TRUE, prmsd=TRUE, msdsize="smaller",middle.bold=TRUE)

##makes no difference from latex(s6) alone with regards to formatting...

Quite frustrating-Any suggestions??


More information about the R-help mailing list