In my case, I was trying to do some process mining on IT help desk-type ticketing system. Because this was some initial exploration, I was using RStudio to create and RMarkdown document in which I could keep track of what I was doing and present some output from the analysis.
The bupaR ecosystem has a package called processmappeR which can create process maps (kind of like a flow chart) from an event log. When knitting the document to HTML, the maps were coming out beautifully, as were the various other figures I was generating. However, when I tried to knit to PDF to share the document with a colleague, I noticed that all of the process maps were missing without a trace.
Long story short, the processmappeR package seems to rely on network graph diagrams that were intended for use in a viewer or Shiny app. After lots of Googling, I came across a thread in the DiagrammeR GitHub repository that had an answer and a link to a more complete discussion by Yihui, the creator of bookdown (https://bookdown.org/yihui/bookdown/html-widgets.html).
The basic idea is to install the webshot package, then use that package to install phantomJS.
install.packages("webshot")
webshot::install_phantomjs()
This essentially takes a screen shot of the graphic that you are trying to render as part of the knitting process. I'm still working on tweaking the resulting images, but the process worked like magic and I now have all of my process maps as part of my PDF document. Awesome!

No comments:
Post a Comment