Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

example of latex table failing. should use pander

  • Loading branch information...
commit 71bcf9c8ebf6efb172f4f78eeca949427b60d9cd 1 parent b5fc66d
@cboettig authored
View
34 basic_knitr_example.Rmd
@@ -1,34 +0,0 @@
-
-
-Knitr Basic Example
-===================
-
-How do I have a random number be reproducible?
-
-``` {r }
-set.seed(123)
-rnorm(10)
-````
-
-
-Make cool graphics we can share the code for. We'll use some inline code to turn on `knitr's` upload function: `r opts_knit$set(upload.fun = imgur_upload) `
-
-
-``` {r }
-library(ggplot2)
-qplot(hp, mpg, data=mtcars)+geom_smooth()
-ggpcp(mtcars) + geom_line()
-````
-
-
-
-## Libraries
-
-These libraries will load without printing any messages to the output.
-
-``` {r message=FALSE}
-library(knitr)
-library(geiger)
-````
-
-Check out [knitr home page](https://knitr.github.com) for details.
View
67 basic_knitr_example.md
@@ -1,67 +0,0 @@
-
-
-Knitr Basic Example
-===================
-
-How do I have a random number be reproducible?
-
-
-
-```r
-set.seed(123)
-rnorm(10)
-```
-
-
-
-```
-## [1] -0.56048 -0.23018 1.55871 0.07051 0.12929 1.71506 0.46092
-## [8] -1.26506 -0.68685 -0.44566
-```
-
-
-
-
-
-Make cool graphics we can share the code for. We'll use some inline code to turn on `knitr's` upload function:
-
-
-
-
-```r
-library(ggplot2)
-qplot(hp, mpg, data = mtcars) + geom_smooth()
-```
-
-
-
-```
-## geom_smooth: method="auto" and size of largest group is <1000, so using loess. Use 'method = x' to change the smoothing method.
-```
-
-![plot of chunk unnamed-chunk-2](http://i.imgur.com/UBdNQ.png)
-
-```r
-ggpcp(mtcars) + geom_line()
-```
-
-![plot of chunk unnamed-chunk-2](http://i.imgur.com/7cNte.png)
-
-
-
-
-## Libraries
-
-These libraries will load without printing any messages to the output.
-
-
-
-```r
-library(knitr)
-library(geiger)
-```
-
-
-
-
-Check out [knitr home page](https://knitr.github.com) for details.
View
0  fix-titles.sh → notebook/fix-titles.sh
File renamed without changes
View
0  fixtags.R → notebook/fixtags.R
File renamed without changes
View
0  fixtitles.R → notebook/fixtitles.R
File renamed without changes
View
19 pandoc_latex_table.Rmd
@@ -0,0 +1,19 @@
+
+We can use xtable to produce latex table formatted in the output.
+```{r results="asis"}
+library(xtable)
+ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
+trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
+group <- gl(2,10,20, labels=c("Ctl","Trt"))
+weight <- c(ctl, trt)
+mytable <- summary(lm(weight ~ group))
+xtable(mytable)
+```
+
+Though the output is markdown, pandoc can regonize the resulting latex block, and render the table.
+Unfortunately, pandoc doesn't like the math markup that comes out in this data table title.
+Consequently,
+
+ pandoc -S pandoc_latex_tables.md -o pandoc_latex.pdf
+
+fails. Deleting the math markup in the table title fixes this.
View
36 pandoc_latex_table.md
@@ -0,0 +1,36 @@
+
+We can use xtable to produce latex table formatted in the output.
+
+```r
+library(xtable)
+ctl <- c(4.17, 5.58, 5.18, 6.11, 4.5, 4.61, 5.17, 4.53, 5.33, 5.14)
+trt <- c(4.81, 4.17, 4.41, 3.59, 5.87, 3.83, 6.03, 4.89, 4.32, 4.69)
+group <- gl(2, 10, 20, labels = c("Ctl", "Trt"))
+weight <- c(ctl, trt)
+mytable <- summary(lm(weight ~ group))
+xtable(mytable)
+```
+
+% latex table generated in R 2.15.3 by xtable 1.7-0 package
+% Mon Mar 18 15:33:52 2013
+\begin{table}[ht]
+\begin{center}
+\begin{tabular}{rrrrr}
+ \hline
+ & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\
+ \hline
+(Intercept) & 5.0320 & 0.2202 & 22.85 & 0.0000 \\
+ groupTrt & -0.3710 & 0.3114 & -1.19 & 0.2490 \\
+ \hline
+\end{tabular}
+\end{center}
+\end{table}
+
+
+Though the output is markdown, pandoc can regonize the resulting latex block, and render the table.
+Unfortunately, pandoc doesn't like the math markup that comes out in this data table title.
+Consequently,
+
+ pandoc -S pandoc_latex_tables.md -o pandoc_latex.pdf
+
+fails. Deleting the math markup in the table title fixes this.
Please sign in to comment.
Something went wrong with that request. Please try again.