I have already asked this question but realised I wasnt being clear enough in my description of the problem and have therefore deleted the original post.
I have two components at play here. First I have my Shiny App, which is shown below:
library(shiny)
library(readxl)
Pre_Match_Odd_Entry <- read_excel("~/Pre Match Odd Entry.xlsx")
ui <- fluidPage(
numericInput("code","Code:",1),
numericInput("min","Minute:",1),
numericInput("hg","Home:",0),
numericInput("ag","Away:",0),
numericInput("edge","Edge:",0.02),
actionButton("runScript", "Get odds"),
tableOutput("market")
)
server <- function(input, output, session) {
mylist <- reactiveVal()
observe({ # create the list
mylist(list(
i_code = input$code,
i_min = input$min,
i_hg = input$hg,
i_ag = input$ag,
i_edge = input$edge
))
})
observeEvent(input$runScript, {
source('~/R/Projects/Scripts/Mean Extraction.R', local = list2env(mylist()))
})
output$market <- renderTable({ market })
}
shinyApp(ui, server)
I take the inputs that the user provides from the shiny app and pass it through to my R Script, which runs a calculation and outputs a data frame, which I want to show in my Shiny App after clicking the "Get Odds" button. This code is outlined below, showing only the inputs from the shiny app and then the final line of the code, which is the data frame output.
# Start R Script #
CODE = i_code
minute = i_min
hs = i_hg
as = i_ag
edge = i_edge
...
(calculations)
...
market <- data.frame(...)
# End R Script#
When I run my shiny app, the error I get is the following: Error in source(market) : object 'market' not found
How do I correctly reference this table in my Shiny code so that I can display the table when I press the "Get Odds" button?
Thanks in advance for your help!