Your EstimateModels.R should contain a function to which you can pass the data frame produced by read.csv as an argument.
I made my own EstimateModels.R that contains the function RSQout that returns the R Squared of a linear fit
RSQout <- function (data) {
FIT <- lm(data$y ~ data$x)
summary(FIT)$r.squared
}
Here is a simple app.R file that allows the user to pick a file to use as the input of RSQout and then shows the R Squared. Notice that I assume the data file has a header for columns labeled x and y.
library(shiny)
ui <- fluidRow(
fileInput('csvFile',"Select file"),
hr(),
uiOutput(outputId = "RSQtext")
)
server <- function(input, output) {
GetRSQ <- eventReactive(input$csvFile, {
data <- read.csv(input$csvFile$datapath, header=TRUE)
source("EstimateModels.R")
RSQout(data)
})
output$RSQtext <- renderText(GetRSQ())
}
# Run the application
shinyApp(ui = ui, server = server)
You probably want to do something much more complicated and eventReactive might not be the best choice for your case.