1

What is the best way to save a visualization from the dm package? I am currently using the viewer to save images made with dm_draw, but this is producing low resolution images and is not ideal.

Example:

dm_nycflights13() %>%
  dm_draw()

I've tried adding png(file_name = "filename.png" and dev.off() to sandwich the dm visualization, but haven't had any luck.

CGP
  • 129
  • 8

2 Answers2

1

For anyone else looking for this, the result of dm_draw() can be piped into DiagrammeRsvg::export_svg().

CGP
  • 129
  • 8
1

You could use the saveWidget function from the htmlwidgets R package. You can change the selfcontained parameter, depending on if you want to save the HTML as a single self-contained file or not.

htmlwidgets::saveWidget(widget = diagr, file = "diagram.html", selfcontained = TRUE)
Esther
  • 356
  • 8