【发布时间】:2014-12-04 02:11:18
【问题描述】:
我正在尝试使用对 renderText 函数的两次连续调用在主页中打印两行反应值。我现在只看到第二个值。
如果我删除第二个 renderText 函数,程序会愉快地打印第一个值,但如果我将第二个 renderText 函数返回给代码,第一个值不会打印,第二个会打印。
我想要一个显示两个反应值(敏感性和特异性)的主页;一旦这个工作正常,我会抛出一些额外的情节。
这是错误的 render* 函数,还是错误的 pageWithSidebar() 函数?
这里是 UI.R 和 server.R 文件。
#ui.R
library(shiny)
# Define UI for application that draws a histogram
shinyUI(pageWithSidebar(
headerPanel("Header"),
mainPanel("Main"),
# Sidebar with a slider input for the number of bins
sidebarLayout(
sidebarPanel(
sliderInput("sensitivity",
"Sensitivity",
min = 0.0,
max = 1.0,
value = 0.8),
sliderInput("specificity",
"Specificity",
min = 0.0,
max = 1.0,
value = 0.4)
),
# Show a plot of the generated distribution
mainPanel({
textOutput("caption1")
textOutput("caption2")
})
)
)
)
and server.R
#server.R
library(shiny)
shinyServer(function(input, output) {
output$caption1 <- renderText(input$sensitivity)
output$caption2 <- renderText(input$specificity)
}
)
【问题讨论】: