我已经问过这个问题,但是意识到我对问题的描述不够清楚,因此删除了原始帖子。
我在这里扮演两个角色。首先,我有我的Shiny App,如下所示:
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)
我将用户从闪亮的应用程序中提供的输入传递给我的R脚本,该脚本运行计算并输出数据框,我想在单击“获取赔率”后显示在我的闪亮应用程序中按钮。下面概述了此代码,仅显示了来自闪亮应用程序的输入,然后显示了代码的最后一行,即数据帧输出。
# 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#
运行闪亮的应用程序时,出现以下错误:源(市场)中的错误:找不到对象“市场”
如何正确地在Shiny代码中引用该表,以便在按下“获取赔率”按钮时可以显示该表?
在此先感谢您的帮助!