'How can I italicize part of a ggplot2 plot title when knitting the figure in an RMarkdown file?
If I'm just working in R to save a plot as a PNG I'm able to use the {ggtext} package to incorporate basic markdown into elements of my plots, but {ggtext} outputs garbled text when I try using element_markdown() in an R chunk.
I've also tried:
my.title <- expression(paste0(italic("Species name"), " Rest of Title"))
ggplot... + labs(title = my.title)
with no luck (when knitting).
Solution 1:[1]
It appears gsub() will do the trick, but I would be interested in knowing if there is a more elegant solution.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | RegalPlatypus |
