2014-02-21 40 views
1

当创建与Knitr在RStudio一个乳胶文档时,输出带有在PDF ##导致像:knitr产生##与表的代码,而不是胶乳文档中的表

## % 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是:

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) 
@ 
+0

请提供一个可重复的例子。这将提供线索。 – mnel

+0

我添加了代码块。 – user3335182

+0

你应该在data.frame中使用'='而不是'<--'。除此之外,还适合我。你会得到什么样的错误(LaTeX?) – baptiste

回答

0
```{r TableName, results='asis', echo = FALSE, message = FALSE} 

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 
) 

print(xtable(dist.freq,caption = "Your caption"), comment=FALSE) 
```