sharoz
sharoz

Reputation: 6345

How to use unicode strings with knitr on windows

Here's a simple markdown file:

---
title: "blah"
output: html_document
---

```{r}
library(tidyverse)

ggplot(tibble(x=1:2)) +
  aes(x=x, y=x) +
  geom_col() +
  labs(y = "← low      high →")
```

Notice the arrows. They show up when running the code via the console to RStudio's plot tab. But for an HTML knit, they don't work:

enter image description here

Upvotes: 4

Views: 76

Answers (1)

acylam
acylam

Reputation: 18691

Use the unicode instead of the actual character:

library(tidyverse)

ggplot(tibble(x=1:2)) +
  aes(x=x, y=x) +
  geom_col() +
  labs(y = "\u2190 low      high \u2192")

enter image description here

Upvotes: 3

Related Questions