Based on the advice in this post I am trying to get the serif font (or 'family' of fonts) installed into R so that I can save ggplots as .eps files. Though the suggestion provided worked I would like to try to resolve the issue for future use.
Here's code to generate the issue.
library(bayesplot)
df <- data.frame(xVar = rnorm(1e4,0,1), yVar = rnorm(1e4,2,1), zVar = rnorm(1e4,4,1))
t <- bayesplot::mcmc_trace(df)
t
Now when I go to save the figure...
ggplot2::ggsave(filename = "tPlot.eps",
plot = t,
device = "eps",
dpi = 1200,
width = 15,
height = 10,
units = "cm")
...it throws the error
Error in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)) :
family 'serif' not included in postscript() device
In the previous post the answerer suggested I download the extrafont
package.
I ran
View(fonttable())
But the serif font did not appear to be installed.
Then I tried
font_addpackage(pkg = "serif")
But I got the error
Error in font_addpackage(pkg = "serif") :
Unknown font package type: not type1 or ttf.
Does anyone know how to install the serif font so R can recognise/use it?