title: How to embed a ggvis chart from an external source in shiny?
body: <p>I got already an answer on pretty much the same topic here <a href="https://stackoverflow.com/questions/24554734/dynamic-ggvis-object-in-shiny">Dynamic ggvis object in Shiny</a>, but I am still stacked with a similar piece of code and I don't really understand why.</p>
  
  <p><strong>ui.R</strong></p>
  
  <pre><code>library(shiny)
  library(ggvis)
  shinyUI(fluidPage(
  
    fluidRow(titlePanel("My app")),
  
      fluidRow(
            column(3,
                   tags$h1('Menu'),
                   radioButtons('colors', label = 'select bars color',
                                      c("Red"='red','Green'='green','Blue'='blue'))
                   ),
            column(9,
                   tags$h1("hello"),
                   ggvisOutput('test1'),
                   tags$h2("Chosen color is",textOutput('testText', inline = T))
                   )
      )
     )
    )
  </code></pre>
  
  <p><strong>server.R</strong></p>
  
  <pre><code>library(shiny)
  library(ggvis)
  shinyServer(function(input, output) {
  source("charts.R")
    output$testText &lt;- reactive({ input$colors })
    input_color &lt;- reactive({ input$colors })
    # cars %&gt;%
    #   ggvis(~speed, fill:= input_color) %&gt;%
    #   layer_bars() %&gt;%
    #   bind_shiny("test1", "test1_ui")
    chart1() %&gt;%
      bind_shiny("test1", "test1_ui")
  })
  </code></pre>
  
  <p><strong>charts.R</strong></p>
  
  <pre><code>chart1 &lt;- reactive({
    cars %&gt;% 
      ggvis(~speed, fill:= input_color) %&gt;% 
      layer_bars() 
  })
  </code></pre>
  
  <p>I would like to call <code>chart1</code> from <code>charts.R</code> into <code>server.R</code>. Everything works with ggvis if I use the commented code in <code>server.R</code>, but it doesn't when I try to call the ggvis function from <code>charts.R</code> (as in the uncommented code).</p>
  
  <p>Also, do you think is a good practice to create multiple .R scripts or shall I go for proper modules?</p>