-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathtime-input.R
60 lines (54 loc) · 1.3 KB
/
time-input.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$h2("Time Input"),
fluidRow(
column(
width = 6,
timeInput(
inputId = "time1",
label = "Time:"
),
verbatimTextOutput("res1"),
timeInput(
inputId = "time2",
label = "Time (default value):",
value = "09:30"
),
verbatimTextOutput("res2"),
timeInput(
inputId = "time3",
label = "Time (with seconds):",
step = 1
),
verbatimTextOutput("res3")
),
column(
width = 6,
timeInput(inputId = "time4", label = "Time:"),
verbatimTextOutput("res4"),
numericInput("up_h", "Update hour;", value = 0),
numericInput("up_m", "Update minute;", value = 0)
)
)
)
server <- function(input, output, session) {
output$res1 <- renderPrint(input$time1)
output$res2 <- renderPrint(input$time2)
output$res3 <- renderPrint(input$time3)
output$res4 <- renderPrint(input$time4)
observe({
updateTimeInput(
inputId = "time4",
value = paste(
# Hour and minute need to be a field of minimum width 2,
# with zero-padding on the left
sprintf("%02d", input$up_h),
sprintf("%02d", input$up_m),
sep = ":"
)
)
})
}
if (interactive())
shinyApp(ui, server)