Usuń dane.nazwy wierszy ramki podczas używania xtable

Ok, przyznaję, że ten jest trochę spięty( Czytaj: "głupi"), i zakładam, że to też dość łatwe. Piszę raport i chcę użyć pakietu xtable do generowania tabeli LaTeX (zauważ, że pakiet memisc spełnia to zadanie, ale powiedzmy, że chcę to zrobić wyłącznie z xtable).

Użyjmy standardowego mtcars zbioru danych i reshape pakietu:

mdtf <- melt(mtcars, id.vars = c("am", "cyl"), measure.vars = c("mpg", "hp", "wt"))
( res <- cast(mdtf, am + cyl ~ variable, mean) )
  am cyl      mpg        hp       wt
1  0   4 22.90000  84.66667 2.935000
2  0   6 19.12500 115.25000 3.388750
3  0   8 15.05000 194.16667 4.104083
4  1   4 28.07500  81.87500 2.042250
5  1   6 20.56667 131.66667 2.755000
6  1   8 15.40000 299.50000 3.370000

Jeśli zawiążę to w xtable, dostanę nazwy wierszy (1..6):

xtable(res)
% latex table generated in R 2.13.0 by xtable 1.5-6 package
% Fri Mar 25 09:40:12 2011
\begin{table}[ht]
\begin{center}
\begin{tabular}{rrrrrr}
  \hline
 & am & cyl & mpg & hp & wt \\ 
  \hline
1 & 0.00 & 4.00 & 22.90 & 84.67 & 2.94 \\ 
  2 & 0.00 & 6.00 & 19.12 & 115.25 & 3.39 \\ 
  3 & 0.00 & 8.00 & 15.05 & 194.17 & 4.10 \\ 
  4 & 1.00 & 4.00 & 28.07 & 81.88 & 2.04 \\ 
  5 & 1.00 & 6.00 & 20.57 & 131.67 & 2.75 \\ 
  6 & 1.00 & 8.00 & 15.40 & 299.50 & 3.37 \\ 
   \hline
\end{tabular}
\end{center}
\end{table}

Teraz, jest jakaś szansa, że mogę tego uniknąć (w jednowierszowej, jeśli możliwe)?

Author: Brian Tompsett - 汤莱恩, 2011-03-25

1 answers

Użyj include.rownames=FALSE w metodzie print. Zobacz ?print.xtable:

R> print(xtable(res), include.rownames=FALSE)

% latex table generated in R 2.12.2 by xtable 1.5-6 package
% Fri Mar 25 10:06:08 2011
\begin{table}[ht]
\begin{center}
\begin{tabular}{rrrrr}
  \hline
am & cyl & mpg & hp & wt \\ 
  \hline
0.00 & 4.00 & 22.90 & 84.67 & 2.94 \\ 
  0.00 & 6.00 & 19.12 & 115.25 & 3.39 \\ 
  0.00 & 8.00 & 15.05 & 194.17 & 4.10 \\ 
  1.00 & 4.00 & 28.07 & 81.88 & 2.04 \\ 
  1.00 & 6.00 & 20.57 & 131.67 & 2.75 \\ 
  1.00 & 8.00 & 15.40 & 299.50 & 3.37 \\ 
   \hline
\end{tabular}
\end{center}
\end{table}
 136
Author: rcs,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2011-03-25 09:08:00