maniA
maniA

Reputation: 1457

How can I print an R macro in Markdown in colour?

I have a print statement in R as a macro in 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!")}
```

and I want to generate a PDF, not an XML! How can I print "all durations are fine!" in colour for example green or red?

Upvotes: 2

Views: 172

Answers (1)

maniA
maniA

Reputation: 1457

Using HERE and HERE and the hints given by User I wrote the following:

 ```{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!}")}
 ```

which solves the problem.

Upvotes: 1

Related Questions