title: Access to a variable inside shiny r and reuse it
body: <p>I have defined a global variable called  y_kmeans in clustering plot as following : and I want to use this variable later in a table:</p>
  
  <p>Server.R</p>
  
  <pre><code>  output$plot4&lt;-renderPlot({
          df&lt;-rawdata()
          #clustering of Related IP address and the number of movie downloads and number of user_id
          df&lt;- na.omit(df)
          df5 &lt;-df[3:4]
          #%&gt;% dplyr::select(user_id,pa_content_name)
          #set.seed(12)
          split &lt;- sample.split(df5, SplitRatio = 0.85)
          training_set &lt;- subset(df5, split == TRUE)
          test_set &lt;- subset(df5, split == FALSE)
          # Feature Scaling
          training_set = scale(training_set)
          test_set = scale(test_set)
          # Using the elbow method to find the optimal number of clusters
          # Fitting K-Means to the dataset
          set.seed(28)
          kmeans = kmeans(x = df5, centers = 3)
          y_kmeans &lt;&lt;- kmeans$cluster
  
        })
  </code></pre>
  
  <p>So To add this variable in a table I have used following codes: </p>
  
  <pre><code>#Demand of titles 
    GroupingVal &lt;- reactive({
      df&lt;-rawdata()
      #Grouping the Values based on clustering
      df$cluster&lt;-kmeans$cluster
      df&lt;-df %&gt;% mutate(group=ifelse(cluster==1,"A",
                                     ifelse(cluster==2,"B",
                                            ifelse(cluster==3,"outlier","outlier"
                                            ))))
      df
    })
  </code></pre>
  
  <p>and the code related to renderDatatable is as follows: </p>
  
  <pre><code> output$filteredtbl&lt;-DT::renderDataTable({
      if(is.null(GroupingVal)){return()}
          DT::datatable(GroupingVal(),extensions="Responsive",options=list(pageLength=3),class='cell-border strip',selection='single')
        })
  </code></pre>
  
  <p>The error that I received is 
  "object of type 'closure' is not subsettable"
  could you please let me know where is the problem. </p>