ここは簡単な例です。
library(shiny)
ui <- shinyUI(fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
selectInput("select", "Select a graph", c("mtcars", "cars"))
),
mainPanel(
conditionalPanel("input.select=='mtcars'",
plotOutput('mtcars')),
conditionalPanel("input.select=='cars'",
plotOutput('cars'))
)
)
))
server <- shinyServer(function(input, output) {
output$mtcars <- renderPlot({
plot(mtcars$mpg, mtcars$disp)
})
output$cars <- renderPlot({
plot(cars$speed,cars$dist)
})
})
shinyApp(ui = ui, server = server)
条件に基づいて出力を表示するには 'conditionalPanel'を使用するか、' renderUI'とサーバーの終了ロジック( 'ifelse'など)を使用してユーザー選択に基づいて出力をレンダリングします。 –
ヒントのおかげで。私は条件付きパネルのいくつかのオプションを試しましたが、これを動作させることはできません。次のようなコードがあります。 – PvC
#mainPanel( id = 'stuff'、 selectInput( "stuff"、label = h5( "犯罪、学校援助または給与データを表示するための選択")、choices = list( "Crime" 条件付きパネル( 'input.stuff === "Crime"、htmlOutput( "crimehotspots"))、 条件付きパネル(' input.stuff === "School" '、htmlOutput ( "教育"))、 条件付きパネル( 'input.stuff === "収入"、htmlOutput( "収入")))、 – PvC