Knitr: print text from code block as R markdown
问题 I have the following R Markdown document: --- title: "Test" output: html_document --- ```{r cars, echo=FALSE} myCondition <- TRUE if(myCondition) { print("## Car Summary") } summary(cars) ``` When I Knit it to HTML, the "Car Summary" header is rendered in "terminal-like" monospaced font as this: ## [1] "## Car Summary" But I want it rendered as a header. How do I achieve this? 回答1: This should work for you: ```{r cars, echo=FALSE, results='asis'} myCondition <- TRUE if(myCondition) { cat("##