2013-03-11 1 views
8

R/반짝이는 웹 앱을 만듭니다. 객관식 상자를 갖고 싶습니다 (checkboxGroupInput()을 사용하지만 대안을 사용할 수 있습니다). 그러나 선택 목록은 길기 때문에 전체 선택 목록을 스크롤 할 수있는 스크롤 막대를 사용하여 상대적으로 작은 옵션 상자 (한 번에 5-6 개 옵션 표시)에 포함하고 싶습니다.R/shiny의 다중 선택 상자 - 스크롤 막대 추가

이 방법을 사용할 수 있습니까? 최소한의 예 :

ui.R

library(shiny) 
choices = paste("A",1:30,sep="_") 

shinyUI(pageWithSidebar(

# Application title 
headerPanel("my title"), 
sidebarPanel( 
    checkboxGroupInput("inp", "choose any of the following", choices) 
), 
mainPanel(
    tableOutput("result") 

) 
)) 

server.R

library(shiny) 
shinyServer(function(input, output) { 
myInput <- reactive({ 
    input$inp 
}) 
output$result <- renderTable({ 
x = myInput() 
if(length(x)==0) { 
x = "No Choice Made" 
} 
matrix(x,ncol=1) 
}) 

}) 

답변

10

나는 selectInput(..., multiple = TRUE)를 사용하여 트릭을한다는 것을 발견했다.