2017-10-16 9 views
1

与えられたスクリプトは添付されたスナップショットを作成します。これはRのDTパッケージを使用して作成されたテーブルです。テーブルの上にメニュー "A"最初のSelectInputでは、2つのスライダーで2番目のselectInputを取得し、1番目のSelectInputで「B」を選択すると、2番目のSelectInputだけを取得し、スライダーは取得しません。テーブルアイリスに変更は必要ありません。助けていただきありがとうございます。RのSelectInputに基づくインタラクティブメニューを追加するShiny

## app.R ## 
library(shiny) 
library(shinydashboard) 
library(DT) 

#Declaring the UI 
ui <- fluidPage(
titlePanel("Interactive Menu"), 

# Create a new Row in the UI for selectInputs 
fluidRow(
column(3, 
    selectInput("names", 
       "Customer:", 
       c("A","B")) 
)), 
fluidRow(

column(4, 
     selectInput("names", 
        "Customer:", 
        c(as.character(iris$Species))) 
), 
column(4, 
     sliderInput("slide", "Select the slider one", 
        min = 75, max = 100, 
        value = 75, step = 5) 

), 
column(4, 

     sliderInput("city", "Select the slider two", 
        min = 60, max = 100, 
        value = 60, step = 10) 
)), 

# Create a new row for the table. 
fluidRow(
DT::dataTableOutput("table1") 
) 
) 
#Declaring the Server 
server <- function(input, output) { 

# Filter data based on selections 
output$table1 <- renderDataTable({ 

datatable(iris, options = list(
    searching = FALSE, 
    pageLength = 5, 
    lengthMenu = c(5, 10, 15, 20) 
)) 
}) 
} 
shinyApp(ui, server) 

iris_capture

+1

[R Shinydashboardのタブの選択に基づくUI要素の表示/非表示](https://stackoverflow.com/questions/39987908/r-shinydashboard-showing-hiding-ui-elements-based-on-tab-選択肢) –

+0

こんにちはHardik、ありがとう、私はこの機能に取り組んだ、私の質問は、このリンクが言っているタブセットの条件パネルと同じ方法で、条件付きパネルでselectInputを実装できるかどうか、また、 、親切に分かち合う。 –

+0

'renderUI'で' conditionalPanel'または 'uiOutput'を使うことができます。 – SBista

答えて

0

は、あなたが提供するコードとあなたが尋ねた出力を使用して実施例である:

## app.R ## 
library(shiny) 
library(shinydashboard) 
library(DT) 

#Declaring the UI 
ui <- fluidPage(
    titlePanel("Interactive Menu"), 

    # Create a new Row in the UI for selectInputs 
    fluidRow(
     column(4, 
     selectInput("names", 
        "Customer:", 
        c("A","B"))) 
    ) 
    , 
    fluidRow(
    conditionalPanel(
     condition = "input.names == 'A'", 
     column(4, 
      selectInput("names", 
         "Customer:", 
         c(as.character(iris$Species))) 
      ), 
     column(4, 
      sliderInput("slide", "Select the slider one", 
         min = 75, max = 100, 
         value = 75, step = 5)), 
     column(4, 
      sliderInput("city", "Select the slider two", 
         min = 60, max = 100, 
         value = 60, step = 10) 
    ) 
    ), 
    conditionalPanel(
     condition = "input.names == 'B'", 
    column(4, 
      selectInput("names", 
         "Customer:", 
         c(as.character(iris$Species))) 
      )) 
    ), 

    # Create a new row for the table. 
    fluidRow(
    DT::dataTableOutput("table1") 
) 
) 
#Declaring the Server 
server <- function(input, output) { 

    # Filter data based on selections 
    output$table1 <- renderDataTable({ 

    datatable(iris, options = list(
     searching = FALSE, 
     pageLength = 5, 
     lengthMenu = c(5, 10, 15, 20) 
    )) 
    }) 
} 
shinyApp(ui, server) 

enter image description here

enter image description here

コメントに記載されているように、このトリックはconditionalPanelです。

+0

偉大なアントワーヌ、私は、ポイントまで完璧にこれが好きです。 –

+0

このリンクでお手伝いしてください。https://stackoverflow.com/questions/46783181/sliderinput-issue-with-table-in-r-shiny –

+0

有用であるとわかっている場合は、回答を受け入れてください。 –

0

あなたはそうのような複数のウィジェットを追加することができます。ここでは

rm(list = ls()) 
library(shiny) 
runApp(list(
    ui = bootstrapPage(
    selectInput('data', 'Data', c('mtcars', 'iris')), 
    uiOutput('columns') 
), 
    server = function(input, output){ 
    output$columns <- renderUI({ 
     mydata <- get(input$data) 
     tagList(
     selectInput('columns2', 'Columns', names(mydata)), 
     selectInput('columns3', 'Columns 2', names(mydata))) 
    }) 
    } 
)) 
+0

ありがとう、すばらしい助け。 –

+0

こんにちは、あなたが私を助けることができるなら、私はこの投稿で少し助けが必要です、https://stackoverflow.com/questions/46766286/slider-not-giving-proper-value-when-pointed-at-100-in-r - 光沢のあるテーブル –

関連する問題