Рендеринг InfoBox с помощью переключателя - PullRequest
0 голосов
/ 27 декабря 2018

Я не могу построить код, который будет отображать '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)

Я получаю ошибку: Ошибка в if (inline) {: аргумент не интерпретируется как логический sample respresent

sample representation

1 Ответ

0 голосов
/ 28 декабря 2018

Вот рабочий пример.

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)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...