You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package provides a `timeInput` widget for Shiny. This widget allows intuitive time input in the
19
-
`[hh]:[mm]:[ss]` (24H) format by using a separate numeric input for each part of the time.
20
-
Setting and getting of the time in R is done with 'DateTimeClasses' objects.
21
+
`[hh]:[mm]:[ss]`or `[hh]:[mm]`(24H) format by using a separate numeric input for each time
22
+
component. Setting and getting of the time in R is done with 'DateTimeClasses' objects.
21
23
22
24
#Usage
23
25
@@ -33,22 +35,31 @@ ui <- fluidPage(
33
35
timeInput("time2", "Time:", value = Sys.time()),
34
36
35
37
# Set to custom time
36
-
timeInput("time3", "Time:", value = strptime("12:34:56", "%T"))
38
+
timeInput("time3", "Time:", value = strptime("12:34:56", "%T")),
39
+
40
+
# Use %H:%M format
41
+
timeInput("time4", "Time:", seconds = FALSE)
37
42
)
38
43
```
39
44
40
-
Note that setting an inital value is done with a [`DateTime`](http://www.inside-r.org/r-doc/base/DateTimeClasses) class,
41
-
in the same way as setting a date in `dateInput` can be done with a `Date` class.
45
+
Note that setting an inital value is done with a
46
+
[`DateTime`](http://www.inside-r.org/r-doc/base/DateTimeClasses) object, in the same way as setting
47
+
a date in `dateInput` can be done with a `Date` object.
42
48
43
-
The value retrieved will alse be in `DateTime` class. You need
44
-
to convert it to character to be able to print the time, as the default character representation
45
-
does not include the time. An example:
49
+
The value retrieved will also be a `DateTime` object. You need to convert it to character to be able
50
+
to print the time, as the default character representation does not include it. An example:
46
51
47
52
```
48
53
server <- function(input, output) {
49
54
# Print the time in [hh]:[mm]:[ss] everytime it changes
50
-
observe(print(strftime(input$time1, "%T"))),
55
+
observe(print(strftime(input$time1, "%T")))
56
+
57
+
# Print the time in [hh]:[mm] everytime it changes
58
+
observe(print(strftime(input$time4, "%R")))
51
59
}
52
60
```
53
61
54
-
For a fully functional app go to the [ShinyApps example](https://burgerga.shinyapps.io/shinyTimeExample/) (can be a bit slow) or try the `shinyTime::shinyTimeExample()` function after installing the package with `install.packages('shinyTime')`.
62
+
For a fully functional app go to the
63
+
[ShinyApps example](https://burgerga.shinyapps.io/shinyTimeExample/) (can be a bit slow) or try the
64
+
`shinyTime::shinyTimeExample()` function after installing the package with
This package provides a `timeInput` widget for Shiny. This widget allows intuitive time input in the `[hh]:[mm]:[ss]` (24H) format by using a separate numeric input for each part of the time. Setting and getting of the time in R is done with 'DateTimeClasses' objects.
7
+
This package provides a `timeInput` widget for Shiny. This widget allows intuitive time input in the `[hh]:[mm]:[ss]`or `[hh]:[mm]`(24H) format by using a separate numeric input for each time component. Setting and getting of the time in R is done with 'DateTimeClasses' objects.
8
8
9
9
Usage
10
10
=====
@@ -19,16 +19,22 @@ As the `shinyTime` package mimics the existing shiny functionality, using the pa
19
19
timeInput("time2", "Time:", value = Sys.time()),
20
20
21
21
# Set to custom time
22
-
timeInput("time3", "Time:", value = strptime("12:34:56", "%T"))
22
+
timeInput("time3", "Time:", value = strptime("12:34:56", "%T")),
23
+
24
+
# Use %H:%M format
25
+
timeInput("time4", "Time:", seconds = FALSE)
23
26
)
24
27
25
-
Note that setting an inital value is done with a [`DateTime`](http://www.inside-r.org/r-doc/base/DateTimeClasses)class, in the same way as setting a date in `dateInput` can done with a `Date`class.
28
+
Note that setting an inital value is done with a [`DateTime`](http://www.inside-r.org/r-doc/base/DateTimeClasses)object, in the same way as setting a date in `dateInput` can be done with a `Date`object.
26
29
27
-
The value retrieved will alse be in`DateTime`class. You need to convert it to character to be able to print the time, as the default character representation does not include the time. An example:
30
+
The value retrieved will also be a`DateTime`object. You need to convert it to character to be able to print the time, as the default character representation does not include it. An example:
28
31
29
32
server <- function(input, output) {
30
33
# Print the time in [hh]:[mm]:[ss] everytime it changes
31
-
observe(print(strftime(input$time1, "%T"))),
34
+
observe(print(strftime(input$time1, "%T")))
35
+
36
+
# Print the time in [hh]:[mm] everytime it changes
37
+
observe(print(strftime(input$time4, "%R")))
32
38
}
33
39
34
40
For a fully functional app go to the [ShinyApps example](https://burgerga.shinyapps.io/shinyTimeExample/) (can be a bit slow) or try the `shinyTime::shinyTimeExample()` function after installing the package with `install.packages('shinyTime')`.
0 commit comments