title: call R script from Shiny App
body: <p>I developed a shiny app which displays some dynamic charts. These charts are generated at execution time according to the value of some buttons. This shiny app gets the data from a raw csv which is previously treated and transformed. I got a Rscript apart from the shiny app to do all those "transformations" of the raw data. What I would like to do is to call this Rscript from the shiny app in order to be executed when the shiny app is launched. </p>
  
  <p>I have already checked these links but it didn't help at all: <a href="https://stackoverflow.com/questions/31376169/how-can-i-connect-r-script-with-shiny-app-in-r">How can I connect R Script with Shiny app in R?</a> and this one <a href="https://stackoverflow.com/questions/21864611/using-source-in-shiny">using Source() in Shiny</a>. I checked the Rstudio documentation too: <a href="http://shiny.rstudio.com/tutorial/lesson5/" rel="noreferrer">http://shiny.rstudio.com/tutorial/lesson5/</a>.</p>
  
  <p>I think it should be something like this, being procesadoDatos.R the RScript. i just want the source command to be executed at the beginning in order to load the data as the shiny app is starting:</p>
  
  <pre><code> source("procesadoDatos.R",local = TRUE)
   shinyServer(function(input, output,session) {
   (renderplots, reactives elements and so on)}
  </code></pre>
  
  <p>The Rscript is the shiny project path as the server.R and UI.R files. I also tried including the path but it didn't work either.</p>
  
  <p>Another thing I tried was to create a function which makes all the transformations and then call it from server.R file after sourcing it:</p>
  
  <pre><code> source("procesadoDatos.R",local = TRUE) 
   generate_data(ticketsByService_report10.csv)
  </code></pre>
  
  <p>Being generate_data this function defined in the RScript:</p>
  
  <pre><code> generate_data &lt;- function(csv_file) {
   (all those transformation, data frame an so on)}
  </code></pre>
  
  <p>In all cases I got the same error saying that the data frames which are generated in the RScript aren't found.</p>
  
  <p>Does anyone know what is wrong? Thanks in adavance</p>