![](/img/trans.png)
[英]knitr::is_word_output() to check if the current output type is word – just like knitr::is_latex_output() and knitr::is_html_output()
[英]Which knitr option controls typeset vs. code-like output from knitr (LaTeX)
有一個名為knit_print
的通用 function,其中包含各種類的方法; 運行methods("knit_print")
以查看它們與您加載的包有什么關系。 如果您的最終 object(可能有類"tbl_df"
、 "tbl"
和"data.frame"
)有一個 class,其中有一個knit_print
方法,這就是它將使用的內容。 運行example(knit_print)
將創建一個data.frame
方法。
從另一個答案來看,似乎是printr
package 添加了knit_print.data.frame
方法。 要解決此問題,您可以使用render
塊選項,例如
```{r}
library(printr)
head(mtcars)
```
```{r render = print}
head(mtcars)
```
產生這個 output:
閱讀vi.nette('knit_print', package = 'knitr')
后,我發現在我的情況下,原因是我在我的 Rnw 文件的序言中盲目地添加了library(printr)
,它產生了格式化的 output(如我的第二個插入的圖像)。 當我注釋掉該行時,output 就像您在控制台中與 R 交互時看到的那樣(如第一張圖片所示)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.