Error: syntax error in line 16 near '('

16 views
Skip to first unread message

akshay tuptewar

unread,
Mar 13, 2023, 1:49:49 AM3/13/23
to Shiny - Web Framework for R
library(shiny)
library(DiagrammeR)

ui <- fluidPage(
  textInput("node_A", " A:",width = '50px'),
  textInput("node_B", " B:",width = '50px'),
  grVizOutput("my_graphviz")
)

server <- function(input, output) {
  output$my_graphviz <- renderDiagrammeR({
    # Convert inputs to integers
    node_A <- as.integer(input$node_A)
    node_B <- as.integer(input$node_B)
   
    # Calculate sum of node A and B
    node_c <- node_A + node_B
   
    my_graphviz <- grViz(paste0("digraph {
         
                     graph[rankdir = LR]
                     
                     node[shape = ellipse, style = filled]  
                     A[label = '", node_A, "']
                     B[label = '", node_B, "']
                     c[label = '", node_c, "']
   
 
                     edge[color = black]
                     A -> B
                     B -> c
           
                     
                     A[label = paste('<table><tr><td><b>Node A</b></td></tr><tr><td><button onclick=\\'alert(\\\"Button clicked!\\\")\\'>Click me</button></td></tr></table>')]

  }"))
    my_graphviz
  })
}

shinyApp(ui, server)
Reply all
Reply to author
Forward
0 new messages