问题
I have problem with my tables when knitting them to PDF - the first table isn't printed properly although I used the same pattern for all 3 tables - the first table is printed partially with code:
I used this code until the first table:
```{r echo=FALSE, warning=FALSE}
library("markdown")
library(xtable)
options(xtable.comment = FALSE)
```
## Aufgabe:
Die durchschnittliche Anzahl an Brüchen für jeden Wolltyp und Druckvariante ist:
```{r echo=FALSE}
round(with(warpbreaks, tapply(breaks, list(wool, tension), mean)),2)
```
## Aufgabe:
```{r echo=FALSE}
a <- as.vector(prop.table(margin.table(UCBAdmissions,c(2,3,1)),c(1,2)))[1:12]
a <- matrix(a,nrow=2)
rownames(a) <- c("Male","Female")
colnames(a) <- c("A","B","C","D","E","F")
```
```{r echo=FALSE}
a <- xtable(a,align=xalign(a),digits=xdigits(a),display=xdisplay(a))
```
```{r results='asis', echo=FALSE}
xtable(a, digits = 1, caption = "Relative Zulassungshäufigkeit (in %) je nach
Department und Geschlecht")
```
How is it possible to print the first table correctly?
回答1:
Wrap the output in a raw tex
block so Pandoc won't touch it:
````{=tex}
```{r results='asis', echo=FALSE}
xtable(a, digits = 1, caption = "Relative Zulassungshäufigkeit (in %) je nach
Department und Geschlecht")
```
````
来源:https://stackoverflow.com/questions/65629639/r-markdown-xtable-is-knitted-partially-with-code-to-pdf