Error in, as.graphicsAnnot(x$label), x$x, x$y, : invalid font type

I am trying to get rmarkdown to output pdf for each of individual id(row). I have Chinese font in the ggplot().

The rmarkdown content looks like this:


chinesetext=theme(text=element_text(family='STXihei')) # add support on chinese in ggplot


The R script looks like this:

for (id in unique(mtcars$carb)){
  subgroup <- mtcars[mtcars$carb == id,]
  render("/Users/mtcars.Rmd",output_format='pdf_document',output_file = paste0('report.', id, '.pdf'))    

I got the error:

Quitting from lines 10-25 (mtcars.Rmd) 
Error in, as.graphicsAnnot(x$label), x$x, x$y,  : 
  invalid font type
In addition: There were 50 or more warnings (use warnings() to see the first 50)

I have tried many solutions people discussed online without any luck. I know this is a font issue, as the error indicated. Has anyone experienced it and worked it out? I can get the code run to output HTML docs, but I really need PDF. Thank you very much.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.