In knitr, no output from pander in for loop

后端 未结 1 782
迷失自我
迷失自我 2021-02-15 00:31

Using knitr in RStudio, pander does not produce any (or correct) html output when in a for loop. Here is a minimal case, as an Rmd input file.

---
title: \"Unt         


        
1条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-15 01:01

    @daroczig answered in the comments :

    1. change knitr chunk option results to asis, either at the global level knitr::opts_chunk$set(results="asis") or at the chunk level ```{r,results="asis"}
    2. disable panderOption knitr.auto.asis : panderOptions('knitr.auto.asis', FALSE)

    Cf. this issue

    ---
    title: "Untitled"
    output: html_document
    ---
    
    Testing **when** pander doesn't work in for loop
    
    ```{r global_options, include=FALSE}
    knitr::opts_chunk$set(fig.width=7, fig.height=5, echo=TRUE, warning=FALSE,
      message=FALSE)
    
    ```
    
    ```{r,results="asis"}
    library(pander)
    panderOptions('knitr.auto.asis', FALSE)
    
    r <- 1:10
    
    for (i in 1:2) pander(summary(r))
    
    ```
    

    0 讨论(0)
提交回复
热议问题