@@ -3,43 +3,64 @@ library(bslib)
33
44# Define UI for slider demo app ----
55ui <- page_sidebar(
6-
76 # App title ----
87 title = " Sliders" ,
98
109 # Sidebar panel for inputs ----
1110 sidebar = sidebar(
12-
13- # Input: Simple integer interval ----
14- sliderInput(" integer" , " Integer:" ,
15- min = 0 , max = 1000 ,
16- value = 500 ),
17-
18- # Input: Decimal interval with step value ----
19- sliderInput(" decimal" , " Decimal:" ,
20- min = 0 , max = 1 ,
21- value = 0.5 , step = 0.1 ),
22-
23- # Input: Specification of range within an interval ----
24- sliderInput(" range" , " Range:" ,
25- min = 1 , max = 1000 ,
26- value = c(200 ,500 )),
27-
28- # Input: Custom currency format for with basic animation ----
29- sliderInput(" format" , " Custom Format:" ,
30- min = 0 , max = 10000 ,
31- value = 0 , step = 2500 ,
32- pre = " $" , sep = " ," ,
33- animate = TRUE ),
34-
35- # Input: Animation with custom interval (in ms) ----
36- # to control speed, plus looping
37- sliderInput(" animation" , " Looping Animation:" ,
38- min = 1 , max = 2000 ,
39- value = 1 , step = 10 ,
40- animate =
41- animationOptions(interval = 300 , loop = TRUE ))
42-
11+ # Input: Simple integer interval ----
12+ sliderInput(
13+ " integer" ,
14+ " Integer:" ,
15+ min = 0 ,
16+ max = 1000 ,
17+ value = 500
18+ ),
19+
20+ # Input: Decimal interval with step value ----
21+ sliderInput(
22+ " decimal" ,
23+ " Decimal:" ,
24+ min = 0 ,
25+ max = 1 ,
26+ value = 0.5 ,
27+ step = 0.1
28+ ),
29+
30+ # Input: Specification of range within an interval ----
31+ sliderInput(
32+ " range" ,
33+ " Range:" ,
34+ min = 1 ,
35+ max = 1000 ,
36+ value = c(200 , 500 )
37+ ),
38+
39+ # Input: Custom currency format for with basic animation ----
40+ sliderInput(
41+ " format" ,
42+ " Custom Format:" ,
43+ min = 0 ,
44+ max = 10000 ,
45+ value = 0 ,
46+ step = 2500 ,
47+ pre = " $" ,
48+ sep = " ," ,
49+ animate = TRUE
50+ ),
51+
52+ # Input: Animation with custom interval (in ms) ----
53+ # to control speed, plus looping
54+ sliderInput(
55+ " animation" ,
56+ " Looping Animation:" ,
57+ min = 1 ,
58+ max = 2000 ,
59+ value = 1 ,
60+ step = 10 ,
61+ animate =
62+ animationOptions(interval = 300 , loop = TRUE )
63+ )
4364 ),
4465
4566 # Output: Table summarizing the values entered ----
@@ -48,30 +69,31 @@ ui <- page_sidebar(
4869
4970# Define server logic for slider examples ----
5071server <- function (input , output ) {
51-
5272 # Reactive expression to create data frame of all input values ----
5373 sliderValues <- reactive({
54-
5574 data.frame (
56- Name = c(" Integer" ,
57- " Decimal" ,
58- " Range" ,
59- " Custom Format" ,
60- " Animation" ),
61- Value = as.character(c(input $ integer ,
62- input $ decimal ,
63- paste(input $ range , collapse = " " ),
64- input $ format ,
65- input $ animation )),
66- stringsAsFactors = FALSE )
67-
75+ Name = c(
76+ " Integer" ,
77+ " Decimal" ,
78+ " Range" ,
79+ " Custom Format" ,
80+ " Animation"
81+ ),
82+ Value = as.character(c(
83+ input $ integer ,
84+ input $ decimal ,
85+ paste(input $ range , collapse = " " ),
86+ input $ format ,
87+ input $ animation
88+ )),
89+ stringsAsFactors = FALSE
90+ )
6891 })
6992
7093 # Show the values in an HTML table ----
7194 output $ values <- renderTable({
7295 sliderValues()
7396 })
74-
7597}
7698
7799# Create Shiny app ----
0 commit comments