[問題] shiny疑問

作者: Tampa (光芒)   2016-11-29 21:43:41
大家好 最近用shiny寫個小程式
上網找樣本然後自己來練習
想請問一下 shiny 是否有個類似開關的物件??
敘述如下
http://i.imgur.com/GmCCY5p.jpg
目前自己做的開關是用0/1來表示
現在想做的構想是,如果橫條選到0
則以下的清單都不可以動作
(畫面暗掉,不能動作,類似這樣的layout)
以下是我的程式碼
ui.r部分
library(shiny)
# Define UI for slider demo application
fluidPage(
# Application title
titlePanel("簡訊通知"),
# Sidebar with sliders that demonstrate various available
# options
sidebarLayout(
sidebarPanel(
# Simple integer interval
sliderInput("開關", "開關:",
min=0, max=1, value=1,step=1),
# Decimal interval with step value
sliderInput("發送時間", "發送時間:",
min = 8, max = 19, value = 1, step= 1,post=":00"),
# Specification of range within an interval
sliderInput("逾時", "逾時:",
min = 0, max = 23 , value = 1,step=1),
# Provide a custom currency format for value display,
# with basic animation
# Animation with custom interval (in ms) to control speed,
# plus looping
sliderInput("發訊時間", "發訊時間:",8, 19, 8,
step = 1, animate=
animationOptions(interval=1000, loop=TRUE))
),
# Show a table summarizing the values entered
mainPanel(
tableOutput("values")
)
)
)
sever.r部分
library(shiny)
# Define server logic for slider examples
function(input, output) {
# Reactive expression to compose a data frame containing all of
# the values
sliderValues <- reactive({
# Compose data frame
data.frame(
setting = c("開關",
"發送時間",
"逾時",
"發訊時間"),
Value = as.character(c(input$開關,
input$發送時間,
paste(input$逾時, collapse=' '),
input$發訊時間)),
stringsAsFactors=FALSE)
})
# Show the values using an HTML table
output$values <- renderTable({
sliderValues()
})
}
以上 感謝各位大大
作者: yenyu0304   2016-11-29 22:14:00
可以用checkbox 來取代開關喔在搭配uiOutput --有勾就看見下面U.i 沒勾就看不見
作者: clansoda (小笨)   2016-11-29 22:25:00
我沒看完你的code,但有這種conditional的需求我建議你用conditionalpanel,在input$xxxx = 1的情況他出現,input$xxxx = 0則消失,連點都不給點

Links booklink

Contact Us: admin [ a t ] ucptt.com