r - R 中的 xtable : Cannot get rid of row numbers

标签 r dataframe latex xtable

我在 R 中创建了一个数据框,如下所示:

estimate1 = rep(1,times=4)
standardError = rep(2, times = 4)
pvalue = runif(4, min=0, max=1)
rowNames =c('Thing1','Things2','Thing3','Thing4')
tableResults = as.data.frame(cbind(rowNames, estimate1, standardError, pvalue))

当我尝试使用以下方式写入文本文件时:

xtable(tableResults, include.rownames=FALSE) 

我得到:

\begin{tabular}{rllll}
  \hline
 & rowNames & estimate1 & standardError & pvalue \\ 
  \hline
  1 & Thing1 & 1 & 2 & 0.624112528283149 \\ 
  2 & Things2 & 1 & 2 & 0.516147756483406 \\ 
  3 & Thing3 & 1 & 2 & 0.756535144057125 \\ 
  4 & Thing4 & 1 & 2 & 0.0105485401581973 \\ 
   \hline
\end{tabular}

我不知道如何删除第一列中的行号。我认为“include.rownames=FALSE”会摆脱它,但这不起作用。

最佳答案

include.rownamesxtable 的 print 函数的参数对象,print.xtable ,而不是 xtable功能。请改用以下代码:

print(xtable(tableResults), include.rownames=FALSE)

% latex table generated in R 3.2.3 by xtable 1.8-2 package
% Wed Jul 06 11:56:20 2016
\begin{table}[ht]
\centering
\begin{tabular}{llll}
  \hline
rowNames & estimate1 & standardError & pvalue \\ 
  \hline
Thing1 & 1 & 2 & 0.405261459294707 \\ 
  Things2 & 1 & 2 & 0.611535826232284 \\ 
  Thing3 & 1 & 2 & 0.482713349396363 \\ 
  Thing4 & 1 & 2 & 0.242787319235504 \\ 
   \hline
\end{tabular}
\end{table}

关于r - R 中的 xtable : Cannot get rid of row numbers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38228342/

相关文章:

latex - 如何在 LaTeX 文档中显示 LaTeX 代码?

ruby-on-rails - 用于 Rails 应用程序的 R 统计包 Gem

r - 我可以将 downloadButton 的标签更新为 Shiny 吗?

python - 进行以下数据帧宽到长格式转换的好方法?

r - 有没有办法在R Markdown的嵌入式LaTeX方程中使用r代码的结果

r - 在 R 文档中包含 Iverson Bracket

r - 如何根据条件从表中创建带有附加行的 data.table

r - data.table 中的 `by` 和 `.EACHI`

python - 如何访问数据框内的字典中的数据并处理丢失的数据

python - 未从 pandas value_counts() 获取 0 索引