【发布时间】:2015-10-16 22:59:57
【问题描述】:
使用 Shiny 构建应用程序时,我遇到了 reactive 调用本地定义函数的问题。
一个仿真例子:
<server.R>
shinyServer(function(input, output) {
myfunc <- function(x) x+1
myreac <- reactive({
y <- myfunc(input$var)
y
})
# print y value test
output$text <- renderText({
myreac <- myreac()
paste("This is your output:",myreac)
})
闪亮的用户界面
shinyUI(fluidPage(
titlePanel("New App"),
sidebarLayout(
sidebarPanel(
helpText("My App"),
selectInput("var",
label = "Choose an option:",
choices = list("1", "2",
"3"),
selected = "1"),
),
mainPanel(
textOutput("text"),
)
)
))
我得到的输出:基本上是空白的:
This is your output:
似乎反应式没有任何输出。我将不胜感激。
【问题讨论】: