How to show code but hide output in RMarkdown?

前端 未结 6 557
生来不讨喜
生来不讨喜 2020-12-13 01:58

I want my html file to show the code, but not the output of this chunk:

```{r echo=True, include=FALSE}
fun <- function(b)
    {
    for(a in b)
        {         


        
6条回答
  •  旧巷少年郎
    2020-12-13 02:46

    For completely silencing the output, here what works for me

    ```{r error=FALSE, warning=FALSE, message=FALSE}
    invisible({capture.output({
    
    
    # Your code here
    2 * 2
    # etc etc
    
    
    })})
    ```
    

    The 5 measures used above are

    1. error = FALSE
    2. warning = FALSE
    3. message = FALSE
    4. invisible()
    5. capture.output()

提交回复
热议问题