harrelfe / Hmisc

Harrell Miscellaneous
Other
210 stars 81 forks source link

three captions instead of one with latex(summaryM()) #10

Closed LaurenSamuels closed 10 years ago

LaurenSamuels commented 10 years ago

Hi! I'm getting three captions for my table, when I want only one. Here's a self-contained example:

set.seed(1)
d <- expand.grid(x1=c('A', 'B'), x2=c('a', 'b', 'c'))
d$y <- runif(nrow(d))
d
latex(
    summaryM(x2 + y ~ x1, data= d, test=TRUE, overall=TRUE, continuous=6 ),
    file="", where="htbp", 
    caption="Descriptive stats and tests of between-group differences for all primary and secondary neuroimaging outcomes", 
    label= "tbl:descrOutcomes",
    exclude1=FALSE,   digits=2, long=TRUE, prmsd=TRUE, 
    npct="both", size="tiny",  
    center="centering")

And here's the output:

%latex.default(cstats, title = title, file = file, append = TRUE,     caption = if (table.env) paste(caption, if (laststrat) legend,         sep = ". "), rowlabel = rowlabel, table.env = table.env,     col.just = col.just, numeric.dollar = FALSE, insert.bottom = if (!noib &&         laststrat && !table.env) legend, rowname = lab, dcolumn = dcolumn,     extracolheads = extracolheads, extracolsize = Nsize, insert.top = if (strat !=         ".ALL.") strat, ...)%
\begin{table}[htbp]
{\tiny
\caption{Descriptive stats and tests of between-group differences for all primary and secondary neuroimaging outcomes. {\scriptsize $a$\ }{$b$\ }{\scriptsize $c$\ } represent the lower quartile $a$, the median $b$, and the upper quartile $c$\ for continuous variables.~~$x\pm s$ represents $\bar{X}\pm 1$ SD.\label{tbl:descrOutcomes}} 
\caption{Descriptive stats and tests of between-group differences for all primary and secondary neuroimaging outcomes. \indent Tests used:\label{tbl:descrOutcomes}} 
\caption{Descriptive stats and tests of between-group differences for all primary and secondary neuroimaging outcomes. \textsuperscript{\normalfont 1}Pearson test; \textsuperscript{\normalfont 2}Wilcoxon test\label{tbl:descrOutcomes}} 
{\centering
\begin{tabular}{lcccc}
\hline\hline
\multicolumn{1}{l}{}&\multicolumn{1}{c}{A}&\multicolumn{1}{c}{B}&\multicolumn{1}{c}{Combined}&\multicolumn{1}{c}{Test Statistic}\tabularnewline
&\multicolumn{1}{c}{{\scriptsize $N=3$}}&\multicolumn{1}{c}{{\scriptsize $N=3$}}&\multicolumn{1}{c}{{\scriptsize $N=6$}}&\tabularnewline
\hline
x2&&&&$ \chi^{2}_{2}=0 ,~ P=1 ^{1} $\tabularnewline
~~~~a&0.33~{\scriptsize~$\frac{1}{3}$}&0.33~{\scriptsize~$\frac{1}{3}$}&0.33~{\scriptsize~$\frac{2}{6}$}&\tabularnewline
~~~~b&0.33~{\scriptsize~$\frac{1}{3}$}&0.33~{\scriptsize~$\frac{1}{3}$}&0.33~{\scriptsize~$\frac{2}{6}$}&\tabularnewline
~~~~c&0.33~{\scriptsize~$\frac{1}{3}$}&0.33~{\scriptsize~$\frac{1}{3}$}&0.33~{\scriptsize~$\frac{2}{6}$}&\tabularnewline
y&{\scriptsize 0.23~}{0.27 }{\scriptsize 0.42} ~(0.35$\pm$0.20)&{\scriptsize 0.64~}{0.90 }{\scriptsize 0.90} ~(0.73$\pm$0.31)&{\scriptsize 0.29~}{0.47 }{\scriptsize 0.82} ~(0.54$\pm$0.31)&$ F_{1,4}=3.5 ,~ P=0.14 ^{2} $\tabularnewline
\hline
\end{tabular}}}

\end{table}
Warning message:
In chisq.test(tab, correct = FALSE) :
  Chi-squared approximation may be incorrect

Thank you! Laurie

LaurenSamuels commented 10 years ago

Sorry, forgot to include version info:

version
               _                           
platform       x86_64-apple-darwin13.1.0   
arch           x86_64                      
os             darwin13.1.0                
system         x86_64, darwin13.1.0        
status                                     
major          3                           
minor          1.0                         
year           2014                        
month          04                          
day            10                          
svn rev        65387                       
language       R                           
version.string R version 3.1.0 (2014-04-10)
nickname       Spring Dance             

& packages:

            Version                                               Depends
Formula       1.1-1                                   R (>= 2.0.0), stats
ggplot2     0.9.3.1                           R (>= 2.14), stats, methods
gmodels    2.15.4.1                                          R (>= 1.9.0)
Hmisc        3.14-4 methods, grid, lattice, survival (>= 2.37-6), Formula
knitr           1.5                                         R (>= 2.14.1)
ltm           1.0-0                     R (>= 2.14.0), MASS, msm, polycor
msm             1.3                                                  <NA>
mvtnorm   0.9-99991                                           R(>= 1.9.0)
polycor       0.7-8                        R (>= 1.9.0), mvtnorm, sfsmisc
QuantPsyc       1.5                                            boot, MASS
rms           4.2-0      Hmisc (>= 3.12-2), survival (>= 2.37-6), SparseM
sfsmisc      1.0-25                  R (>= 2.11.0), stats, methods, utils
SparseM        1.03                   R (>= 2.4.1), methods, stats, utils
vimcom       0.9-93                                                  <NA>
harrelfe commented 10 years ago

This has been fixed for the next release, which should be in 2 weeks. If you need a source file override for now you can get the latest source for summaryM.s in github. Frank

On 05/22/2014 11:13 AM, LaurenSamuels wrote:

set.seed(1) d <- expand.grid(x1=c('A', 'B'), x2=c('a', 'b', 'c')) d$y <- runif(nrow(d)) d latex( summaryM(x2 + y ~ x1, data= d, test=TRUE, overall=TRUE, continuous=6 ), file="", where="htbp", caption="Descriptive stats and tests of between-group differences for all primary and secondary neuroimaging outcomes", label= "tbl:descrOutcomes", exclude1=FALSE, digits=2, long=TRUE, prmsd=TRUE, npct="both", size="tiny", center="centering")

LaurenSamuels commented 10 years ago

Thank you!