在选择单选按钮时,我无法构建将呈现“ infoBox”的代码。
代码如下:
library(shiny)
library(shinydashboard)
ui <- shinyUI(
fluidPage(h5("D"),
mainPanel(
tabsetPanel(type = "tab",
tabPanel(
fluidRow(
radioButtons("rad", "Select box",
c("1" = "norm",
"2" = "unif")
norm <- box(h3("Super")
infoBox("10", "ab", width = 6)
infoBox("11", "bc", width = 6)
),
unif <-box(h3("Duper")
infoBox("20", "cd", width = 6)
infoBox("21", "de", width = 6)
)))))))
infoBoxOutput("loc")
server <- shinySever(function(input, output){
output$loc <- {(
renderinfoBox(input$rad)
)}
})
shinyApp(ui, server)
答案 0 :(得分:0)
这是一个可行的示例。
library(shiny)
library(shinydashboard)
ui <- shinyUI(fluidPage(h5("D"),
mainPanel(
tabsetPanel(type = "tab",
tabPanel("T1"),
tabPanel(
"T2",
fluidRow(radioButtons(
"rad",
"Select box",
c("1" = "norm", "2" = "unif")
),
infoBoxOutput("loc"))
))
)))
server <- function(input, output) {
output$loc <- renderInfoBox({
if (input$rad == "norm") {
box(h3("Super"),
infoBox("10", "ab", width = 6),
infoBox("11", "bc", width = 6))
} else{
if (input$rad == "unif") {
box(h3("Duper"),
infoBox("20", "cd", width = 6),
infoBox("21", "de", width = 6))
}
}
})
}
shinyApp(ui, server)