R Markdown: xtable is knitted partially with code to PDF

旧街凉风 提交于 2021-02-10 18:19:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!