Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove data.frame row names when using xtable

Tags:

r

latex

report

People also ask

How do I remove row names from a DataFrame in R?

Method 2: Assigning row names to NULL In case, the row names are explicitly assigned to the rows, then using rownames(df) to NULL, deletes the row names and uses row numbers to access the rows.

How do I delete a row name?

To remove the row names or column names from a matrix, we just need to set them to NULL, in this way all the names will be nullified.

What does row names false do in R?

The default (is back compatible), FALSE , will signal an error, where NA will “automatic” row names and TRUE will call make.


Use include.rownames=FALSE in the print method. See ?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}