Show an R markdown chunk in the final output

前端 未结 3 1950
余生分开走
余生分开走 2020-12-19 20:46

I am writing on a presentation using Knitr, Markdown and Slidify. The slides will be partly deal with Knitr as topic which is the reason why I stumbeld upon a problem. I ca

3条回答
  •  感动是毒
    2020-12-19 21:26

    Very late to the party, but this also seems to work:

    ```{r echo=FALSE, class.output="r", comment=""}
    cat("```{r}\nx <- 1 + 1\nx\n```")
    ```
    

    Or, equivalent but perhaps nicer to read and write:

    ```{r echo=FALSE, class.output="r", comment=""}
    cat(paste(sep = "\n",
      "```{r}",
      "x <- 1 + 1",
      "x",
      "```"
    ))
    ```
    

提交回复
热议问题