title: Reactive igraph with r shiny
body: <p>I am relatively new to R and I wonder how to create a reactive igraph in shiny. I am trying to build a shiny app that analyzes Airbnb data. Overall I want to visualize a bipartite network that shows the connection between the listing_id of the apartment and the reviewer_id of the reviewer in an interactive fashion.</p>
  
  <p>I tried to base the graph on a reactive filter that filters the data based on a neighborhood (input from the UI). The graph itself should show connections between listing_ids based on common reviewer_ids (i.e. Listing A is connected to Listing B if they have at least 1 reviewer in common). </p>
  
  <p>The code that I have so far is: </p>
  
  <pre><code>#---------------UI----------
  ui &lt;- fluidPage(
  
    sidebarLayout(position = "right",
      sidebarPanel(h3("Input Parameters"),
  
                   selectInput("neighborhood.selection", "Select the neighborhood you want to display", 
                               c("Manhattan", "Brooklyn", "Queens", "Staten Island",
                                 "Bronx")),
                   #textOutput("o.neighborhood.selection"),
                   #selectInput("vertex.selection", "Select the Vertex you want to display", 
                               #c("Reviewer ID" = 1, "Listing ID" = 2)),
                   ),
      mainPanel(h2("Overall Network Graph"),
                plotOutput("o.big.network")
  
                )
    ),
  )
  
  #-----------server----------
  
  library(igraph)
  library(shiny)
  library(data.table)
  library(rsconnect)
  library(dplyr)
  
  dt.merged &lt;- readRDS("dt.merged.final.rds")
  dt.merged$reviewer_id &lt;- paste0("0", dt.merged$reviewer_id)
  dt.merged &lt;- dt.merged[1:500]
  
  server &lt;- function(input, output) {
  dt.merged.reactive &lt;- reactive({
    req(input$neighborhood.selection)
    filter(dt.merged,neighbourhood_group_cleansed %in% input$neighborhood.selection)
  })
  
    all.listings &lt;- dt.merged.reactive()[, list(name=unique(listing_id), type=TRUE)]
    all.reviewers &lt;- dt.merged.reactive()[, list(name=unique(reviewer_id), type=FALSE)]  
    all.vertices &lt;-   list(all.listings,all.reviewers)
    output$o.big.network  &lt;- renderPlot({
      # Creating the graph
      g &lt;- graph.data.frame(dt.merged.reactive()[, list(listing_id, reviewer_id)], directed=FALSE, vertices= all.vertices) 
    })
  }
  
  </code></pre>