rdm

I get Error: invalid version specification ‘0,2’ when I use the function dm_draw() in r


I want to use the function dm_draw() to visualize a object but when I ran the command I get the error message " Error: invalid version specification ‘0,2’". I've tried the code included in the vignette "Visualizing dm objects" (https://cran.r-project.org/web/packages/dm/vignettes/tech-dm-draw.html) and I get the same error message when I run the dm_draw() function.

library(dm)
library(dplyr)
flights_dm_w_many_keys <- dm_nycflights13(color = FALSE)
dm_draw(flights_dm_w_many_keys)

I'm using dm version 0.2.7 and DiagrammeR 1.0.8. R version 4.1.2

I'm looking for a solution to visualize a dm object, it can be also different from dm_draw(). I hope someone can help me to get that done. Sorry for my broken English and thanks for your time, any type of help is appreciated.


Solution

  • You can use this code:

           library(dm)
           library(dplyr)
           library(DiagrammeR)
           library(DiagrammeRsvg)
           
           # Use this function
           dm_draw_svg = function(dm,...) {
             if (!requireNamespace("DiagrammeRsvg", quietly = TRUE)) {
               stop(
                 "Package \"DiagrammeRsvg\" must be installed to use this function.",
                 call. = FALSE
               )
             }
             
             dm::dm_draw(dm = dm, ...) %>%
               DiagrammeRsvg::export_svg() %>%
               htmltools::HTML() %>%
               htmltools::html_print()
           }
           
           flights_dm_w_many_keys <- dm_nycflights13(color = FALSE)
           # plot
           dm_draw_svg(flights_dm_w_many_keys)
    

    Output: enter image description here