标签: r markdown knitr r-markdown sweave
我在R中的打印声明是Markdown
R
Markdown
```{r chunk_name, echo=FALSE} if ( any(so.results$Duration <0.0)) {print("there are non-positive durations") } else {print("all durations are fine!")} ```
我希望生成PDF,而不是XML!如何打印"all durations are fine!"颜色,例如绿色或红色?
"all durations are fine!"
答案 0 :(得分:1)
使用HERE和HERE以及User提供的提示,我写了以下内容:
```{r, results='asis', echo=FALSE} if ( any(so.results$Duration <0.0)) {cat("\n") print("\textcolor{blue} {print("there are non-positive durations}") } else {cat("\n") print("\textcolor{red}{print("all durations are fine!}")} ```
解决了这个问题。