私はチェックボックスから複数のものを選択できる光沢のあるアプリを作成しようとしています。入力に基づいて、関連するすべてのテキスト出力フィールドを返す必要があります。これを行うにはチェックボックスから複数の入力が返され、複数のテキスト出力が返される
、私は、チェックボックスをインデックスし、if文で複数の条件を使用しますが、input1
を選択したときに何かが動作しませんよ。私はinput2
とinput1
の両方を選択した場合、それはただの結果を示しinput2
; input1
を選択すると、光沢のあるアプリがクラッシュします。
私はチェックするために条件を追加しようとしましたが、運はありません。以下
コード:
library(shiny)
library(shinydashboard)
ui <- shinyUI(
navbarPage("DBC Comparison",
tabPanel("Stats" ,
sidebarLayout(
sidebarPanel(
checkboxGroupInput("comp_type", "Comparison type", choices = c("input1", "input2", "input3")),
actionButton(
inputId = "submit_loc",
label = "Submit")
, width = 3),
mainPanel(
fluidRow(
column(6, textOutput("selected_var1")),
#DT::dataTableOutput("table")#,
# div(style = 'overflow-x: scroll', tableOutput('table'))
column(6,textOutput("selected_var2"))
), position="left"))
)
))
##
##
server <- shinyServer(function(input, output) {
observeEvent(
eventExpr = input$submit_loc,
handlerExpr =
{
if(input$comp_type[1] == 'input2' || input$comp_type[2] == 'input2' || (input$comp_type[1] == 'input1' & input$comp_type[2] == 'input2'))
{
output$selected_var2 <- renderText({
"2"
})}
else if(input$comp_type[1] == 'input1' ||input$comp_type[2] == 'input1'||input$comp_type[3] == 'input1'|| (input$comp_type[1] == 'input1' & input$comp_type[2] == 'input2')
|| (input$comp_type[2] == 'input1' & input$comp_type[1] == 'input2')
{
output$selected_var1 <- renderText({
"1"
})
}
})
})
##
shinyApp(ui = ui, server = server)
任意のアイデア?
これは私が探していたものですが、if文では%in%を使用していましたが、 – Barbara