3

I have really been enjoying using and creating graphs in DiagrammeR so far. I am able to create them in RStudio. Recently I was preparing a shiny app to include a graph using DiagrammeR (grViz function), I checked on the github and found examples of how to do the same (see here).
However I been trying but unable to get the output in a Shiny app. Please find the below code which I am trying (app.R) :

library(DiagrammeR)
library(shiny)

diagram <- "
digraph {

      # graph attributes
      graph [overlap = true]

      # node attributes
      node [shape = box,
      fontname = Helvetica,
      color = blue]

      # edge attributes
      edge [color = gray]

      # node statements
      A; B; C; D; E
      F [color = black]

      # node attributes
      node [shape = circle,
      fixedsize = true,
      width = 0.9]

      # node statements
      1; 2; 3; 4; 5; 6; 7; 8

      # edge statements
      A->1; B->2                   // gray
      B->3 [color = red]           // red
      B->4                         // gray
      C->A [color = green]         // green
      1->D; E->A; 2->4; 1->5; 1->F // gray
      E->6; 4->6; 5->7; 6->7       // gray
      3->8 [color = blue]          // blue
      }
"

# Shiny app
server <- function(input, output) {
    output$diagram <- renderGrViz({
        grViz({
            diagram
        })
    })
}

ui <- fluidPage(
    grVizOutput('diagram', width = "100%", height = "760px") 
)

shinyApp(ui = ui, server = server)

I am using R version 3.6.0, with shiny version 1.4.0, DiagrammeR version 1.0.5 on Windows 10 in Rstudio version 1.2.1335. On executing the above code I always get the following error and the Shiny app does not open.

> runApp()

Listening on http://127.0.0.1:4391
Warning: Error in htmlwidgets::shinyRenderWidget: unused argument (evn = env)
  50: renderGrViz
  49: server [C:\Users\HomeUser\Documents\RWorkSpace\SampleApp/app.R#46]
Error in htmlwidgets::shinyRenderWidget(expr = expr, outputFunction = grVizOutput,  : 
  unused argument (evn = env)

Can anyone guide as to what is wrong with above code ?

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
Shank
  • 63
  • 4
  • that's strange, your code works for me (R 3.6.2, RStudio 1.2.1335, shiny_1.4.0, DiagrammeR_1.0.1) on Linux Ubuntu 18.04.3, did you try to add ```session``` in ```function(input, output)```? No idea if this will work – bretauv Jan 22 '20 at 10:04

1 Answers1

1

I got the same error message as you, but when I downgraded the DiagrammeR package to 1.0.1 everything worked fine.

library(devtools)
install_version("DiagrammeR", version = "1.0.1", repos = "http://cran.us.r-project.org")
motch
  • 458
  • 4
  • 13
  • This no longer woks as the `rgexf` package is no longer available. `devtools::install_version("DiagrammeR", version = "1.0.1") ... ERROR: dependency ‘rgexf’ is not available for package ‘DiagrammeR’` – rvernica Jan 27 '20 at 23:49
  • 1
    with the current dev version (‘1.0.5.9000’) this error also disappears. – SeGa Jan 29 '20 at 09:10