[问题] 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