1
1
library(shiny )
2
+ library(" linelist2ts" )
3
+ data(hagelloch.obk )
4
+ df <- hagelloch.obk @ individuals
2
5
3
6
# Define UI for application that draws a histogram
4
7
shinyUI(fluidPage(
5
-
8
+
6
9
# Application title
7
10
titlePanel(" Interactive time series" ),
8
-
11
+
9
12
# Sidebar with a slider input for the number of bins
10
13
sidebarLayout(
11
14
sidebarPanel(
12
-
13
- selectInput(" var" ,
15
+
16
+ selectInput(" var" ,
14
17
label = " Sex:" ,
15
18
choices = c(" all" , " male" , " female" ),
16
19
selected = " all" ),
17
-
18
- selectInput(" var2" ,
20
+
21
+ selectInput(" var2" ,
19
22
label = " Break by:" ,
20
23
choices = c(" days" , " weeks" , " months" ),
21
24
selected = " weeks" ),
22
-
25
+
23
26
sliderInput(" range" ,
24
27
" Dates:" ,
25
28
min = as.numeric(min(df $ ERU )),
26
29
max = as.numeric(max(df $ ERU )),
27
30
# format = '_locale.date.format', #'M/d/yyyy h:mm a', animate=TRUE,
28
31
# dateInput("ana", "Choose a date:", value = min(df$ERU)),
29
32
value = c(as.numeric(min(df $ ERU )),as.numeric(max(df $ ERU )))),
30
-
33
+
31
34
dateInput(" ana" , " Choose a date:" , value = min(df $ ERU ))
32
-
35
+
33
36
),
34
-
37
+
35
38
# Show a plot of the generated distribution
36
39
mainPanel(
37
-
40
+
38
41
singleton(tags $ head(HTML(
39
42
'
40
43
<script type="text/javascript">
@@ -48,14 +51,14 @@ shinyUI(fluidPage(
48
51
var ref_date = new Date("2014-07-01");
49
52
// each slider step is 1 day, translating to 24 * 3600 * 1000 milliseconds
50
53
var slider_date = new Date(ref_date.getTime() + value * 24 * 3600 * 1000);
51
- return [slider_date.getUTCFullYear(),
52
- slider_date.getUTCMonth() + 1,
54
+ return [slider_date.getUTCFullYear(),
55
+ slider_date.getUTCMonth() + 1,
53
56
slider_date.getUTCDate()].join("-");
54
57
}
55
58
})
56
59
</script>
57
60
' ))),
58
-
61
+
59
62
plotOutput(" distPlot" )
60
63
)
61
64
)
0 commit comments