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

4
  • 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. Commented Mar 7, 2017 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 :) Commented Mar 8, 2017 at 9:01
  • can I send two variables from a script to another using source() function? Commented Mar 8, 2017 at 9:08
  • I think this what you are looking for: stackoverflow.com/questions/14525580/… Commented Mar 8, 2017 at 12:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.