2017-04-11 4 views
0

小さな光沢のあるアプリには、次のような光沢があります。私はすべてのアクションを選択ボタンを作成しました。次に、「すべて選択」ボタンをクリックすると、どのようにすべて(A1、...、C2)を選択できますか?Rstudioの光沢のあるツールをすべて選択したアクションボタン

#ui script 
library(shiny) 
fluidPage(
    selectizeInput("select", "Select multiple", multiple = T, 
    choices = c("A1", "A2", "B1", "B2", "C1", "C2")), 
    actionButton("selectall", "Select all:") 
) 
#server script 
server <- function(input, output){ 
} 

答えて

0

これは必要なものですか?

rm(list = ls()) 
library(shiny) 
mychoices <- c("A1", "A2", "B1", "B2", "C1", "C2") 

ui <- fluidPage(
    selectInput("campaigns", "Choose campaign(s):", multiple = T, choices = mychoices), 
    actionButton("selectall", "Select all:") 
) 
server <- function(input, output, session) { 
    observeEvent(input$selectall,{ 
    if (input$selectall%%2 == 0){ 
     updateSelectInput(session,"campaigns","Choose campaign(s):",choices=mychoices) 
    } 
    else{ 
     updateSelectInput(session,"campaigns","Choose campaign(s):",choices=mychoices,selected=mychoices) 
    } 
    }) 
} 
runApp(list(ui = ui, server = server)) 
+0

はい!ありがとうございました。 – Sumeda

関連する問題