[R] Hmisc::latex() help

Michael Kubovy kubovy at virginia.edu
Fri May 8 00:35:51 CEST 2009


Dear R-helpers,

I have a data frame (info[[j]]) that looks like this:

   necklace originalPosition same run surprise1 pair        surprise2  
triple        surprise3
1        1                1    0   2  2.709511   11  
4.81884167930642    110 2.70951129135145
2        1                2    0   2  2.709511   10                 
1    000                1
3        0                3   NA  NA        NA   00              
<NA>    001             <NA>
4        0                4   NA  NA        NA   00              
<NA>    100             <NA>
5        0                5   NA  NA        NA   00              
<NA>    000             <NA>
6        0                6   NA  NA        NA   00              
<NA>    011             <NA>
7        0                7   NA  NA        NA   00              
<NA>    000             <NA>
8        0                8   NA  NA        NA   01              
<NA>    000             <NA>

I produce a LaTeX table with:

j <- 1
latex(object = info[[j]], file = paste('info', j, '.tex', sep = ''),  
rowlabel = NULL, booktabs = TRUE, here = TRUE, caption =  
paste(df[j, ], collapse = ''), na.blank = TRUE, dcolumn = TRUE, cdec =  
c(0, 0, 0, 0, 2, 0, 2, 0, 2))

However, na.blank and cdec make no difference, producing:

\newcolumntype{.}{D{.}{.}{-1}}
\begin{table}[H]
  \caption{11000000\label{info}}
  \begin{center}
  \begin{tabular}{lD{.}{.}{-1}D{.}{.}{-1}D{.}{.}{-1}D{.}{.}{-1}D{.}{.} 
{-1}llll}\toprule
\multicolumn{1}{l}{necklace}&\multicolumn{1}{c}{originalPosition}& 
\multicolumn{1}{c}{same}&\multicolumn{1}{c}{run}&\multicolumn{1}{c} 
{surprise1}&\multicolumn{1}{c}{pair}&\multicolumn{1}{c}{surprise2}& 
\multicolumn{1}{c}{triple}&\multicolumn{1}{c}{surprise3}& 
\multicolumn{1}{c}{necklace}\tabularnewline
\midrule
1&1&1&~0&~2&2.71&11&4.81884167930642&110&2.70951129135145\tabularnewline
2&1&2&~0&~2&2.71&10&1&000&1\tabularnewline
3&0&3&&&&00&NA&001&NA\tabularnewline
4&0&4&&&&00&NA&100&NA\tabularnewline
5&0&5&&&&00&NA&000&NA\tabularnewline
6&0&6&&&&00&NA&011&NA\tabularnewline
7&0&7&&&&00&NA&000&NA\tabularnewline
8&0&8&&&&01&NA&000&NA\tabularnewline
\bottomrule
\end{tabular}

\end{center}

\end{table}

I presume that this is due to the mixed nature of the columns.

Suggestions for a fix? (I am also not clear on when R produces NA or  
<NA>

Thanks,
MK


_____________________________
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
Parcels:    Room 102        Gilmer Hall
       McCormick Road    Charlottesville, VA 22903
Office:    B011    +1-434-982-4729
Lab:        B019    +1-434-982-4751
Fax:        +1-434-982-4766
WWW:    http://www.people.virginia.edu/~mk9y/




More information about the R-help mailing list