1

I am trying to run my shinyapp.R (includes ui and server) using source("model.R"). I want to let a user upload a data file and run model.R in my shinyapp.R.

How should I let model.R run using user uploaded data set. It does not read the dataset I uploaded from the shiny app.

My code:

source("model.R") server <- function(input, output){ dataset <- reactive({ infile <- input$datafile if( is.null(infile) ) { return(NULL) } else { as.data.frame(read.csv(infile$datapath, header=TRUE)) } }) output$plot <- renderPlot({pred_plot}) }) ui <- fluidPage(fileInput("datafile", "Choose data file", accept = c('text/csv','.csv','.xlsx') ), mainPanel(plotOutput("plot") ) runApp(list(ui = ui, server = server)) 

I get the following error message:

Error in eval(ei, envir) : object 'dataset' not found

1
  • 1
    did you just code line every line one by one? Commented Jul 11, 2018 at 7:38

1 Answer 1

1

I was able to figure it out, I save necessary functions as R objects and call it in shiny app. That way, you can render things as needed.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.