【发布时间】:2014-02-21 00:57:11
【问题描述】:
在 RStudio 中使用 Knitr 创建 LaTeX 文档时,PDF 结果中的输出带有##,如下所示:
## % latex table generated in R 3.0.2 by xtable 1.7-1 package
## % Thu Feb 20 21:49:34 2014
## \begin{table}[ht]
我尝试了一些选项,例如:
<<results='asis'>>=
但编译器无法创建 PDF。
有什么线索吗?
我的会话信息是:
sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252
[3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] xtable_1.7-1 lattice_0.20-24
loaded via a namespace (and not attached):
[1] evaluate_0.5.1 formatR_0.10 grid_3.0.2 knitr_1.5.22 stringr_0.6.2 tools_3.0.2
代码块:
<<>>=
library(xtable)
Frequencia <- c(3,2,3,4,5,11,14,14,4)
Soma <- sum(Frequencia)
dist.freq <- data.frame(
Intervalo <- c("10-19","20-29","30-39","40-49","50-59","60-69","70-79","80-89","90-99"),
Ponto.Medio <- c(14.5, 24.5, 34.5, 44.5, 54.5, 64.5, 74.5, 84.5, 94.5),
Frequencia,
Frequencia.Relativa <- Frequencia / Soma
)
x <- xtable(dist.freq)
print(x)
@
【问题讨论】:
-
请提供一个可重现的例子。这将提供线索。
-
我添加了代码块。
-
您应该在 data.frame 中使用
=而不是<-。除此之外对我来说很好。你得到什么错误(LaTeX?) -
我从
-
您的示例代码块没有 results = 'asis'.....
标签: r latex knitr rstudio xtable