Eli*_*Eli 3 latex r dataframe 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))
Run Code Online (Sandbox Code Playgroud)
当我尝试使用以下方法写入文本文件时:
xtable(tableResults, include.rownames=FALSE)
Run Code Online (Sandbox Code Playgroud)
我得到:
\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}
Run Code Online (Sandbox Code Playgroud)
我不知道如何摆脱第一列中的行号。我以为“ include.rownames = FALSE”会摆脱它,但这是行不通的。
include.rownames是xtable对象的打印功能(而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}
Run Code Online (Sandbox Code Playgroud)