I would like to create a tex table using xtable() . Here is my minimal example that worked when I used the same R version on Win 7.
\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}
Instead of a good table, I get the output of the xlatex() text code in a pdf document.
Here's the output of 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
The testing-xtable code testing-xtable should be reflected in the final document, but it is not. This is a PDF output. I am suspicious of the message Ordinary text without R code . This is normal?
Any help would be greatly appreciated.
r knitr xtable
Gerome bochmann
source share