DiagrammeR in Shiny Presentation

744 views
Skip to first unread message

Matt Brigida

unread,
Jul 4, 2015, 1:57:14 PM7/4/15
to shiny-...@googlegroups.com
I can't seem to get DiagrammeR working in a shiny presentation.  I am able to produce the diagram outside of shiny.  Within shiny I get "Error: no such file or directory".  Example code is below.  I have updated to the latest packages.  Any help is appreciated.

---
title: "Example"
author: "Matt Brigida"
date: "July 4, 2015"
output: ioslides_presentation
runtime: shiny
---

##

```{r, echo=FALSE, message=FALSE, warning=FALSE}
library(DiagrammeR)
inputPanel(
    selectInput("test", "Test", choices = c("Choice 1" = "1", "Choice 2" = "2"), selected = "1")
    )

renderGrViz({
    if (input$test == 1){
        grViz("
  digraph {
    layout = twopi
    node [shape = circle]
    A -> {B C D}
  }")

    } else {
        grViz("
  digraph {
    layout = twopi
    node [shape = circle]
    B -> {A C D}
  }")
    }
})
```


> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux stretch/sid

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DiagrammeR_0.7 shiny_0.12.1   vimcom_1.1-0   setwidth_1.0-3 colorout_1.1-0

loaded via a namespace (and not attached):
 [1] Rcpp_0.11.6      digest_0.6.8     mime_0.3         R6_2.1.0        
 [5] xtable_1.7-4     jsonlite_0.9.16  formatR_1.2      magrittr_1.5    
 [9] evaluate_0.7     stringi_0.5-5    rstudioapi_0.3.1 rmarkdown_0.7   
[13] tools_3.2.1      stringr_1.0.0    htmlwidgets_0.5  httpuv_1.3.2    
[17] yaml_2.1.13      compiler_3.2.1   htmltools_0.2.6  knitr_1.10.5    


Karim Mezhoud

unread,
Aug 14, 2015, 12:40:39 PM8/14/15
to Shiny - Web Framework for R
Hi,
Try this code. it works fine for me.
Karim Mezhoud

server.R

shinyServer(function(input, output, session) {
  output$diagram <- renderGrViz({
  grViz('
    digraph{
      size = "4,4";
      main [shape = box]; #/* this is a comment */
        main -> parse [weight = 8];
      parse -> execute;
      main -> init [style = dotted];
      main -> cleanup;
      execute -> { make_string; printf}
      init -> make_string;
      edge [color = red]; # so is this
      main -> printf;
      node [shape = box, style = filled, color = ".7 .3 1.0"];
      execute -> compare;
    }
    ')

})
})


ui.R

shinyUI(
  grVizOutput('diagram')
)
Reply all
Reply to author
Forward
0 new messages