
答案1
感謝@daroczig 為我解決了這個問題!正如他的評論中提到的,透過使用pander()
而不是print(pandoc.table())
,我得到了想要的結果。此外,使用此方法時無需results = 'asis'
在區塊選項中指定。下面是修改後的程式碼:
```{r echo=F}
library('pander')
tab1 <- data.frame(foo=c('dog', 'cat', 'sheep', 'goat'),bar=1:4)
pander(tab1, caption = "Example")
```