0

I´m new using R and I would like to call from a script to another using source() function and by the way,passing some parameters. This are my two R scripts:

Server.r

library(shiny)

shinyServer(function(input, output) {

  #esta funcion guarda el csv cargado
  filedata <- reactive({
    infile <- input$datafile
    if (is.null(infile)) {

      return(NULL)
    }
    read.csv(infile$datapath, sep = ";")

  })


  filedata1 <- reactive({
    infile1 <- input$datafile1
    if (is.null(infile1)) {

      return(NULL)
    }
    read.csv(infile1$datapath, sep = ";")



  })




  observeEvent(input$do, {

    source("C:/.../app1.R", params=filedata, params=filedata1, local = TRUE)
  })

app.r

...
csv1=read.csv("filedata", sep = ";")
csv2=read.csv("filedata1", sep = ";")
...

I don´t know how to send both .csv inserted (filedata, filedata1) from Server.r to app.r.

Thank you very much in advance

  • Why? What you are doing does not make sense. You have already read the csv in **Server.R**. In fact you are not even passing CSV's to `app.R` You can put R code outside of the ``shinyServer` function and it will be sourced when the shinyApp is spun up or you can put the code in `global.R` with similar results. – emilliman5 Mar 07 '17 at 14:31
  • My code may have no sense, but the thing is that I want to read the .csv from the **server.r** and send both to **app.r**. Imagine something like this: **server.r** a<- read.csv(csv1) and send that variable 'a' to **app.r** to work with it. thank you :) –  Mar 08 '17 at 09:01
  • can I send two variables from a script to another using source() function? –  Mar 08 '17 at 09:08
  • I think this what you are looking for: https://stackoverflow.com/questions/14525580/how-to-pass-command-line-arguments-when-source-an-r-file – emilliman5 Mar 08 '17 at 12:49

0 Answers0