当我在一个非常简单的 Shiny 应用程序中按下操作按钮时,我试图调用另一个 Shiny 的应用程序。另一个应用程序位于一个带有 ui.R 和 server.R 文件的名为 Benefits 的文件夹中,但是当我单击该按钮时,什么也没有发生。有可能我正在尝试做什么吗?
干杯。
用户界面
library(shiny)
shinyUI(fluidPage(
# Application title
titlePanel("RunnApp"),
mainPanel(
actionButton("goButton", "Go!")
)
))
服务器
library(shiny)
shinyServer(function(input, output) {
ntext <- eventReactive(input$goButton, {
runApp("benefits")
})
})
最佳答案
临时答复:
我已经开始寻找这个问题的答案。这个答案会及时更新。
#server.R
library(shiny)
shinyServer(function(input, output) {
ntext <- eventReactive(input$goButton, {
stopApp(runApp('C:/Users/Infinite Flash/Desktop/Dashboard'))
})
output$nText <- renderText({
ntext()
})
})
#ui.R
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("actionButton test"),
sidebarPanel(
actionButton("goButton", "Go!"),
p("Click the button to update the value displayed in the main panel.")
),
mainPanel(
textOutput("nText")
)
))
这段代码的伟大之处在于它初始化了我用
stop(runApp('C:/Users/Infinite Flash/Desktop/Dashboard'))
指定的应用程序。陈述。我可以验证它确实运行了该应用程序,因为我在该应用程序中有一个 global.R 文件,该文件具有 6 个应用程序需要在启动之前加载的预加载数据集。我知道它运行了,因为在这行代码运行后,我的环境中有这些对象(由引用应用程序中的 global.R 文件创建)。棘手的问题是我在(我认为这是问题所在)时收到此错误,它初始化引用的应用程序:
收听 http://127.0.0.1:7908
handlers$add(handler, key, tail) 错误: key /已在使用
目前这种 Shiny 界面的错误超出了我的知识范围。要调试此错误,我需要进行调查。
关于runapp从其他带有操作按钮的 Shiny 应用程序中 Shiny ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33592785/