0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PickerInputのeventReactiveの組み合わせ

Posted at

はじめに

shinywidgetsのPickerInputとactionButtonを実装したので、メモする。

コード

ui.r
library(shiny)
library(leaflet)
library(shinyWidgets)



shinyUI(fluidPage(
  
  titlePanel("TEST"),
  
  #sidebarLayout settings
  sidebarLayout(
    sidebarPanel(
      pickerInput(
        inputId = "PickerID", 
        label = "testlabel", 
        choices = LETTERS, 
        options = list(
          `actions-box` = TRUE, 
          size = 7,
          `selected-text-format` = "count > 3"
        ),
        multiple = TRUE,
      ),
      actionButton("do","RUN!")
    ),
    #mainpanel settings
    mainPanel(
      textOutput("distText")
      )
    )
  ))
server.r
library(shiny)
library(leaflet)
library(dplyr)
shinyServer(function(input, output) {
  
  output$distText <- renderText({
    print(outtext())
  })
  
  outtext <- eventReactive(input$do,{
    print(input$PickerID)
    return(input$PickerID)
  })
})

#おわりに
actionButtonの位置を間違えてせいで1時間以上苦戦してしまった。。。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?