Reputation: 53
I am trying to display special characters in an ioslides_presentation generated with rmarkdown, but instead of a Δ I always get <U+0394> in my final slides. When I execute the individual R chunk it stores Δ correctly. How do I ensure UTF-8 characters are processed correctly using rmarkdown?
Δendo=ΔEC
test <- c("Δendo", "ΔEC")
test
Upvotes: 1
Views: 226
Reputation: 2821
Worth reading: 9.2 Essentials of text data [Neth, H. (2020). ds4psy: Data Science for Psychologists]
R allows typing Unicode characters by entering backslash
as the escape character \u...
or \U...
— with ...
standing for a 4-digit hexadecimal code.
We can show up Unicode characters/symbols in R Markdown documents by using the asis_output()
function of the knitr
package:
---
title: "Untitled"
author: "K"
date: "2 11 2020"
output: ioslides_presentation
---
## Teste
```{r teste, echo = FALSE}
test <- knitr::asis_output(c("\u0394endo", "\u0394EC"))
test
```
## Teste 1
```{r teste1, echo = FALSE}
test1 <- knitr::asis_output("\u0394endo=\u0394EC")
test1
```
## Embed into inline chunk
- We can directly embed into inline chunk the `knitr::asis_output()` function:
- When I execute the individual R chunk it stores `r knitr::asis_output("\u0394")` correctly.
- `r knitr::asis_output("\u0394endo=\u0394EC")`
Upvotes: 2