Search code examples
rrstudiopdf-generation

Rmd markdown to pdf knitr conversion error


I am trying to knit a .rmd markdown to an pdf document. Everything works fine, except for one code block where I am creating a general network visualization with ggplot.

ggraph(enron_weighted_und, layout = "stress") +
  geom_edge_link0(aes(edge_width = weight), edge_colour = "grey66") +
  geom_node_point(aes(fill = clu, size = degree **2), shape = 21) +
  geom_node_text(aes(filter = Pos == "CEO", label = Name, family = "sans", 
                       fontface="bold", size=1300)) +
  scale_fill_manual(values = colour_palette) +
  scale_edge_width_continuous(range = c(0.1, 2.5)) +
  scale_size_continuous(range = c(1, 6)) +
  theme_graph() + 
  theme(legend.position = "bottom")

The error i get: Error in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, : invalid font type Calls: ... drawDetails -> drawDetails.text -> grid.Call.graphics

The code itsself is working properly if I just run the plain .rmd file in rStudio. Ironically, everything does also work when I try to convert it into a html-document. But with pdf, the described error arises.

I haven´t found this error anywhere and don´t get this strange behaviour of .rmd. Every help is welcome!


Solution

  • Found the solution on github: https://github.com/thomasp85/ggraph/issues/260

    Just insert another font family and size into them_graph(), then it´s working!