Dear all, After spending all day and most of the night on this I did a new R-installation and it works. The question now is - upon running this code (from the Hmisc library-latex function) I believe the call to summary.formula is allright, but the latex command results in a totally different table where all the numbers and test columns are wrong are wrong. Is this still a matter for the installation or is there something in the latex syntax I havent grasped?
//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) Produces nice tables-but the numbers are all wrong as you can see below from the latex file... > 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{tabular} \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 expression prostate<-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 On 16. juni 2010, at 20.10, Kevin E. Thorpe wrote: > moleps wrote: >> Dear R´ers I´m trying to get a summary table using latex and summary in the >> rms package to no avail. I´m running R 2.10.1, Mac OS X snow leopard and I >> have the mactex 2009 distribution installed. Any obvious things I´m missing? >> //M >> 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)) >> f <- summary(treatment ~ age + sex + Symptoms, method="reverse", test=TRUE) >> latex(f) >> results in the following: >> This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009) >> entering extended mode >> (/var/folders/q9/q9COp2FREsikCyHB7w+OxE+++TI/-Tmp-//RtmpVIk0iB/file587f83cb.tex >> LaTeX2e <2009/09/24> >> Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, >> noh >> yphenation, german-x-2009-06-19, ngerman-x-2009-06-19, ancientgreek, ibycus, >> ar >> abic, basque, bulgarian, catalan, pinyin, coptic, croatian, czech, danish, >> dutc >> h, esperanto, estonian, farsi, finnish, french, galician, german, ngerman, >> mono >> greek, greek, hungarian, icelandic, indonesian, interlingua, irish, italian, >> ku >> rmanji, latin, latvian, lithuanian, mongolian, mongolian2a, bokmal, nynorsk, >> po >> lish, portuguese, romanian, russian, sanskrit, serbian, slovak, slovenian, >> span >> ish, swedish, turkish, ukenglish, ukrainian, uppersorbian, welsh, loaded. >> (/usr/local/texlive/2009/texmf-dist/tex/latex/base/report.cls >> Document Class: report 2007/10/19 v1.4h Standard LaTeX document class >> (/usr/local/texlive/2009/texmf-dist/tex/latex/base/size10.clo)) >> (/usr/local/texlive/2009/texmf-dist/tex/latex/geometry/geometry.sty >> (/usr/local/texlive/2009/texmf-dist/tex/latex/graphics/keyval.sty) >> (/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifpdf.sty) >> (/usr/local/texlive/2009/texmf-dist/tex/generic/oberdiek/ifvtex.sty) >> (/usr/local/texlive/2009/texmf-dist/tex/xelatex/xetexconfig/geometry.cfg)) >> No file file587f83cb.aux. >> *geometry auto-detecting driver* >> *geometry detected driver: dvips* >> Overfull \hbox (1.14412pt too wide) in paragraph at lines 9--23 >> [] [1] (./file587f83cb.aux) >> LaTeX Warning: Label(s) may have changed. Rerun to get cross-references >> right. >> ) >> (see the transcript file for additional information) >> Output written on file587f83cb.dvi (1 page, 1620 bytes). >> Transcript written on file587f83cb.log. >> sh: xdvi: command not found > > I believe there is something in the latex help page in the rms package that > talks about preview difficulties on MAC. > > -- > Kevin E. Thorpe > Biostatistician/Trialist, Knowledge Translation Program > Assistant Professor, Dalla Lana School of Public Health > University of Toronto > email: kevin.tho...@utoronto.ca Tel: 416.864.5776 Fax: 416.864.3016 ______________________________________________ R-help@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.