根據this答案我可以使用include.rownames=FALSE
來禁止使用xtable
(將r輸出轉換爲LaTeX表的程序包)打印行名稱。例如:R層次結構和傳遞參數來糾正函數
數據:
> head(dataset)
order original prediction anomaly.score abs.o.p
1 1 0 0 1 0
2 2 0 0 1 0
3 3 0 0 1 0
4 4 0 0 0 0
5 5 0 0 0 0
6 6 0 0 0 0
印刷與行名稱:
> xtable(head(dataset))
% latex table generated in R 3.1.1 by xtable 1.8-0 package
% Sun Dec 20 18:38:13 2015
\begin{table}[ht]
\centering
\begin{tabular}{rrrrrr}
\hline
& order & original & prediction & anomaly.score & abs.o.p \\
\hline
1 & 1 & 0 & 0 & 1.00 & 0 \\
2 & 2 & 0 & 0 & 1.00 & 0 \\
3 & 3 & 0 & 0 & 1.00 & 0 \\
4 & 4 & 0 & 0 & 0.00 & 0 \\
5 & 5 & 0 & 0 & 0.00 & 0 \\
6 & 6 & 0 & 0 & 0.00 & 0 \\
\hline
\end{tabular}
\end{table}
打印無行名稱:
> print(xtable(head(dataset)), include.rownames=FALSE)
% latex table generated in R 3.1.1 by xtable 1.8-0 package
% Sun Dec 20 18:49:34 2015
\begin{table}[ht]
\centering
\begin{tabular}{rrrrr}
\hline
order & original & prediction & anomaly.score & abs.o.p \\
\hline
1 & 0 & 0 & 1.00 & 0 \\
2 & 0 & 0 & 1.00 & 0 \\
3 & 0 & 0 & 1.00 & 0 \\
4 & 0 & 0 & 0.00 & 0 \\
5 & 0 & 0 & 0.00 & 0 \\
6 & 0 & 0 & 0.00 & 0 \\
\hline
\end{tabular}
\end{table}
正如你可以看到include.rownames=FALSE
是論據print
功能不爲xtable
。這怎麼可能?是不是xtable
只是將結果打印到標準輸出? print
在使用include.rownames=FALSE
時如何知道要省略?參考頁面還提到?print.xtable
。這是什麼意思?是print.xtable
某種特殊的印刷品,或者xtable
方法從包print
調用或者發生了什麼?
謝謝。你能推薦一些關於這方面的好消息嗎?我發現了這三個網站:http://bit.ly/1hWRxTN http://bit.ly/1OhqHMw http://bit.ly/1Pf0Vpe,但更實際的總結信息從這將是沒有問題的。 –
也許:http://adv-r.had.co.nz/S3.html,http://adv-r.had.co.nz/OO-essentials.html和http://www.dummies.com /how-to/content/how-to-dispatch-to-a-method-in-r.html。 –