itsMeInMiami
itsMeInMiami

Reputation: 2669

Render computed HTML in RMarkdown

I have a function that produces some html and I want RMarkdown to render the html.

```{r}
outputFromAFunction <- '<span style="background-color: #A6CEE3">A</span>'
outputFromAFunction
```

How do I tell rmarkdown to render outputFromAFunction as the colored letter A instead of simply printing the html as text.

I have already tried the results='asis' code chunk option and it removes the closing span tag and does not render the html.

I need to render a html page not shiny.

Upvotes: 0

Views: 73

Answers (1)

Kent Johnson
Kent Johnson

Reputation: 3388

Use results='asis' and cat the value:

```{r results='asis'}
outputFromAFunction <- '<span style="background-color: #A6CEE3">A</span>'
cat(outputFromAFunction)
```

Upvotes: 1

Related Questions