knitr不会在R 3.0.2上转换xtable输出

Ger*_*ann 8 r xtable knitr

我想创建一个tex表使用xtable().这是我在Win 7上使用相同R版本时的最小例子.

\documentclass[a4paper,12pt,twoside]{article}

\begin{document}

<<load-packages,include=TRUE,echo=TRUE>>=
library(xtable)
@

<<testing-xtable,echo=TRUE,cache=FALSE,include=TRUE>>=
tab <- matrix(1:50,nrow=10)
rownames(tab) <- letters[1:10]

print(
  xtable(
    x=tab,
    caption="A table",
    label="tab",
    align=rep("c",times=6),
    digits=3,
    display=rep("f",times=6)
    ), 
  sanitize.colnames.function=identity,
  include.rownames=FALSE,
  table.placement="h"
  )
@
\end{document}
Run Code Online (Sandbox Code Playgroud)

我得到xlatex()了pdf文档中的逐字代码输出,而不是一个好的表.

这是knitr的输出:

> grDevices::pdf.options(useDingbats = FALSE); require(knitr); opts_knit$set(concordance     = TRUE); knit('xtable.Rnw', encoding='UTF-8')
Loading required package: knitr


processing file: xtable.Rnw
  |.............                                                    |  20%
  ordinary text without R code

  |..........................                                       |  40%
label: load-packages (with options) 
List of 2
 $ include: logi TRUE
 $ echo   : logi TRUE

  |.......................................                          |  60%
  ordinary text without R code

  |....................................................             |  80%
label: testing-xtable (with options) 
List of 3
 $ echo   : logi TRUE
 $ cache  : logi FALSE
 $ include: logi TRUE

  |.................................................................| 100%
  ordinary text without R code


output file: xtable.tex

[1] "xtable.tex"
> 
> 
Running pdflatex on xtable.tex...completed

Created PDF:             ~/Dropbox/intern/sandbox(coding)/tex/chapter/chapter/sandbox/xtable/xtable.pdf

Issues: 2 badboxes
Run Code Online (Sandbox Code Playgroud)

代码块testing-xtable应该在最终文档中回显,但事实并非如此.这是pdf输出.我对这个消息很怀疑Ordinary text without R code.这是正常的吗?

任何帮助将不胜感激.

Yih*_*Xie 7

使用块选项 results='asis'.