From: moleps islon <moleps2_at_gmail.com>

Date: Fri, 18 Jun 2010 07:32:52 +0200

table(symptom1,symptom2)

f <- summary(treatment ~ age + sex + Symptoms, method="reverse", test=TRUE) g <- summary(treatment ~ age + sex + symptom1, method="reverse", test=TRUE)

\begin{table}[!tbp]

\multicolumn{1}{l}{}&\multicolumn{1}{c}{Drug}&\multicolumn{1}{c}{Placebo}&\multicolumn{1}{c}{Test

Statistic}\tabularnewline

\hline

*\end{tabular}
*

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 18 Jun 2010 - 06:08:56 GMT

Date: Fri, 18 Jun 2010 07:32:52 +0200

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 ?

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

latex(g)

> 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, ...)%

\begin{table}[!tbp]

\caption{Descriptive Statistics by treatment\label{g}} \begin{center} \begin{tabular}{lccc}\hline\hline

\multicolumn{1}{l}{}&\multicolumn{1}{c}{Drug}&\multicolumn{1}{c}{Placebo}&\multicolumn{1}{c}{Test

Statistic}\tabularnewline

&\multicolumn{1}{c}{{\scriptsize

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

\hline

age&1&1&4\tabularnewline

sex~:~m&6&7&2\tabularnewline

symptom1~:~Depressed&4&3&3\tabularnewline

~~~~Hangnail&5&6&1\tabularnewline ~~~~Headache&4&2&1\tabularnewline ~~~~Muscle~Ache&3&5&1\tabularnewline ~~~~Stomach~Ache&2&4&1\tabularnewline

\hline

\end{center}

\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

\end{table}

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

rm(list=ls())

library(Hmisc)

getHdata(prostate)

# 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 expressionprostate<-upData(prostate, moveUnits=TRUE,units=c(wt="", hg="g/100*ml"),labels=c(wt="Weight Index = wt(kg)-ht(cm)+200"))

attach(prostate)

stage<- factor(stage, 3:4, c("Stage 3","Stage 4"))
s6<-summary(stage~rx+age+wt+pf+hx+sbp+dbp+ekg+hg+sz+sg+ap+bm,method="reverse",
overall=TRUE, test=TRUE)

options(digits=2)

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??

//M

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 18 Jun 2010 - 06:08:56 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Fri 18 Jun 2010 - 13:50:33 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*