[R] Convert ftable to latex?

Fredrik Karlsson dargosch at gmail.com
Tue Aug 30 13:20:31 CEST 2005


Dear list, 

I cannot make the latex command to output a ftable objet the way I
want it. Is it posible?
I found a post in the archives saying that one should use the rgroup
and n.rgroup arguments to supply the row names, but so far I have been
unsuccessful.

This is what I have:

> (ftable(tapply(worksub$vot,list(votcat=worksub$votcat,age=worksub$agemF,voicetype=worksub$Type),FUN="distribution.table.fun",digits=4)) -> ftab)
                  voicetype                  Voiced   Voiceless
unaspirated     Voiceless aspirated
votcat    age
Prevoiced 18 - 24           46.6158 (0;-1.6652)     40.7417
(0;-0.6489)     48.4164 (0;-1.0483)
          24 - 30           50.5716 (0;-1.4244)**   43.4056
(-1;-0.4537)*** 24.204 (0;-2.1416)
          30 - 36           44.4439 (0;-1.182)*     51.0996
(0;-1.5241)***  32.1219 (0;-1.5007)
          36 - 42           40.8604 (-1;-0.3423)    40.6045
(-1;-0.408)**   32.7949 (0;-2.75)
          42 - 48           46.301 (0;-1.1878)      21.6894
(0;-1.7041)     NA (NA;NA)
          48 - 54           38.0151 (-1;-0.7878)*   27.6954
(-1;0.0396)*    NA (NA;NA)
Short lag 18 - 24           7.5719 (1;0.4391)***    9.7039
(1;-0.2938)***   8.5525 (1;-0.4063)***
          24 - 30           8.3466 (1;-0.3122)***   9.8524
(0;-0.887)***    11.4154 (0;-1.2267)***
          30 - 36           9.4509 (1;-0.0795)***   9.0177
(1;-0.2654)***   9.441 (0;-0.7625)
          36 - 42           9.4921 (1;-0.1835)***   10.107 (0;-0.72)**
     10.912 (0;-1.3619)
          42 - 48           7.8254 (1;1.016)**      9.5687 (0;-0.9019)
     10.6842 (-1;0.0719)*
          48 - 54           7.7332 (1;1.2834)**     9.4626
(1;0.3173)***    10.0508 (0;-1.4876)
Long lag  18 - 24           16.7312 (0;-1.7286)     21.4786
(2;2.4726)**    41.6646 (1;-0.6796)***
          24 - 30           29.5637 (1;-0.0951)**   37.4517
(1;0.1032)***   38.2729 (1;-0.3249)***
          30 - 36           23.0214 (0;-1.3023)     35.0403
(1;0.9176)***   36.0989 (1;-0.2141)***
          36 - 42           10.579 (1;0.3292)       31.4878
(0;-1.2475)     38.0472 (1;-0.3049)**
          42 - 48           17.9077 (1;-1.2857)     26.8651
(1;0.0221)***   30.5705 (1;-0.5866)***
          48 - 54           18.832 (0;-2.3333)      40.375 (1;-1.417)*
     26.2463 (1;0.4025)***
> latex(ftab,cgroup=attributes(ftab)$col.vars$voicetype, rgroup=attributes(ftab)$row.vars$votcat, n.rgroup=c(6,6,6),file="")
% latex.default(ftab, cgroup = attributes(ftab)$col.vars$voicetype,   
  rgroup = attributes(ftab)$row.vars$votcat, n.rgroup = c(6,         
6, 6), file = "")
%
\begin{table}[!tbp]
 \begin{center}
 \begin{tabular}{lclcl}\hline\hline
\multicolumn{1}{c}{\bfseries Voiced}&
\multicolumn{1}{c}{\bfseries }&
\multicolumn{1}{c}{\bfseries Voiceless unaspirated}&
\multicolumn{1}{c}{\bfseries }&
\multicolumn{1}{c}{\bfseries Voiceless aspirated}
\\ \cline{1-5}
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{}
\\ \hline
&&&&\\
46.6158 (0;-1.6652)&&40.7417 (0;-0.6489)&&48.4164 (0;-1.0483)\\
50.5716 (0;-1.4244)**&&43.4056 (-1;-0.4537)***&&24.204 (0;-2.1416)\\
44.4439 (0;-1.182)*&&51.0996 (0;-1.5241)***&&32.1219 (0;-1.5007)\\
40.8604 (-1;-0.3423)&&40.6045 (-1;-0.408)**&&32.7949 (0;-2.75)\\
46.301 (0;-1.1878)&&21.6894 (0;-1.7041)&&NA (NA;NA)\\
38.0151 (-1;-0.7878)*&&27.6954 (-1;0.0396)*&&NA (NA;NA)\\
\hline
&&&&\\
7.5719 (1;0.4391)***&&9.7039 (1;-0.2938)***&&8.5525 (1;-0.4063)***\\
8.3466 (1;-0.3122)***&&9.8524 (0;-0.887)***&&11.4154 (0;-1.2267)***\\
9.4509 (1;-0.0795)***&&9.0177 (1;-0.2654)***&&9.441 (0;-0.7625)\\
9.4921 (1;-0.1835)***&&10.107 (0;-0.72)**&&10.912 (0;-1.3619)\\
7.8254 (1;1.016)**&&9.5687 (0;-0.9019)&&10.6842 (-1;0.0719)*\\
7.7332 (1;1.2834)**&&9.4626 (1;0.3173)***&&10.0508 (0;-1.4876)\\
\hline
&&&&\\
16.7312 (0;-1.7286)&&21.4786 (2;2.4726)**&&41.6646 (1;-0.6796)***\\
29.5637 (1;-0.0951)**&&37.4517 (1;0.1032)***&&38.2729 (1;-0.3249)***\\
23.0214 (0;-1.3023)&&35.0403 (1;0.9176)***&&36.0989 (1;-0.2141)***\\
10.579 (1;0.3292)&&31.4878 (0;-1.2475)&&38.0472 (1;-0.3049)**\\
17.9077 (1;-1.2857)&&26.8651 (1;0.0221)***&&30.5705 (1;-0.5866)***\\
18.832 (0;-2.3333)&&40.375 (1;-1.417)*&&26.2463 (1;0.4025)***\\
\hline
\end{tabular}

\end{center}

\end{table}

> 

As you can see, I do not get any row names, and I want two layers of
them (votcat and age in the formula). Column names work ok.

Please, help me recreate the table above in latex form (if it is
indeed possible).

/Fredrik




More information about the R-help mailing list