[英]xtable in .Rmd then knit as pdf in rstudio shows % comments
在編寫R Markdown(.Rmd)文件時,我正在使用Rstudio的'knit PDF'選項制作PDF。
使用xtable函數創建表時,使用%在latex中注釋的文本顯示在pdf中。 使用latex和R編織.Rnw文件時,這個問題就消失了。
下面是一個.Rmd文件的例子,它被編織為PDF和等效的.Rnw文件,以編織(自然為pdf)。
他們的PDF結果是相同的,除了一行。 在表格上方,顯示以下內容:
R 3.1.0由xtable 1.7-3包裝生成的%乳膠表%2014年8月6日星期三19:06:37
---
output: pdf_document
---
```{r, results='asis'}
library(xtable)
xtable(summary(cars))
```
\documentclass{article}
\begin{document}
<<r, results='asis'>>=
library(xtable)
xtable(summary(cars))
@
\end{document}
r中xtable(summary(cars))
表達式的實際輸出如下。 您可以看到前兩行,以%
開頭。不同之處在於.Rnw文件隱藏了它們而.Rmd文件則沒有。
% latex table generated in R 3.1.0 by xtable 1.7-3 package
% Wed Aug 06 19:33:18 2014
\begin{table}[ht]
\centering
\begin{tabular}{rll}
\hline
& speed & dist \\
\hline
1 & Min. : 4.0 & Min. : 2.00 \\
2 & 1st Qu.:12.0 & 1st Qu.: 26.00 \\
3 & Median :15.0 & Median : 36.00 \\
4 & Mean :15.4 & Mean : 42.98 \\
5 & 3rd Qu.:19.0 & 3rd Qu.: 56.00 \\
6 & Max. :25.0 & Max. :120.00 \\
\hline
\end{tabular}
\end{table}
我假設問題是針織的.Rmd文件不能將%
識別為乳膠注釋,從而打印出來。 我如何擺脫桌面上方的這些線條? 有沒有辦法讓.Rmd文件將%
識別為注釋?
正如@celiomsj所說,使用comment
參數print.xtable
並將其設置為FALSE
以省略參數:
print(xtable(summary(cars)), comment=FALSE)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.