Menu

R: Set Font Based on Output Device

by jtth

Jan 16, 2018

Ever had a troublesome font in R that doesn’t want to render to ggplot in RStudio, but will render just fine in knitr? Do you use extrafont but sometimes it just doesn’t work? Trying to look like Tufte’s Visual Display of Quantitative Information but ETBembo is being uncooperative? Try setting your font (globally) to this.

This sets myfont to serif if the code is being rendered in anything but knitr. If it is being rendered by knitr, say, by pressing the “Knit” button in RStudio, then it sets it to ETBembo.

I found it on StackOverflow.

Related categories:

Site menu

Back to top