-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
169 lines (157 loc) · 4.3 KB
/
app.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
library(shiny)
library(suncalc)
library(plotrix)
library(sonicscrewdriver)
library(schite)
year <- as.POSIXlt(Sys.Date())$year + 1900
ui <- fluidPage(
# Application title
titlePanel("Daylight Information"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("date",
"Date:",
min = as.Date(paste0(year,"-01-01"),"%Y-%m-%d"),
max = as.Date(paste0(year,"-12-31"),"%Y-%m-%d"),
value = Sys.Date(),
timeFormat = "%Y-%m-%d",
step = 3,
animate = animationOptions(interval = 250,loop=TRUE)
),
selectInput("loc",
"Location:",
c("NHM", "York", "Houndwood", "Lyme Regis",
"Rovaniemi", "Austin", "Sydney"),
selected = "York",
multiple = FALSE,
selectize = TRUE,
width = NULL,
size = NULL
),
checkboxGroupInput("times",
"Time of day:",
choices = c(
"Sunrise",
"Sunset",
"Solar Noon",
"Civil Twilight",
"Nautical Twilight",
"Astronomical Twilight",
"Night",
"Nadir"
),
selected = c(
"Sunrise",
"Sunset",
"Civil Twilight",
"Nautical Twilight",
"Astronomical Twilight",
"Night"
),
),
selectInput("display",
"Display:",
c("Main", "Core", "Ring"),
selected = "Main",
multiple = FALSE,
selectize = TRUE,
width = NULL,
size = NULL
),
checkboxInput("legend",
"Show legend",
value = FALSE
)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("distPlot"),
tabsetPanel(type = "tabs",
tabPanel("How to cite", htmlOutput("citation")),
tabPanel("Data Calculation", htmlOutput("citecalc")),
tabPanel("Data Visualisation", htmlOutput("citevis")),
tabPanel("Misc", htmlOutput("citmisc"))
)
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output, session) {
citation <- list(
cite_bibentry(
bibentry(
bibtype = "Misc",
title = "Daylight Information Example",
author = "Ed Baker",
url = "http://shiny.ebaker.me.uk/shiny-diel/",
year = 2022
)
)
)
output$citation <- citationTabUI(citation)
citcalc <- list(
cite_r_package("suncalc")
)
output$citecalc <- citationTabUI(citcalc)
citvis <- list(
cite_r_package("sonicscrewdriver"),
cite_r_package("plotrix")
)
output$citevis <- citationTabUI(citvis)
citmisc <- list(
cite_r_package("schite"),
cite_r_package("shiny")
)
output$citmisc <- citationTabUI(citmisc)
output$distPlot <- renderPlot({
if (input$loc == "NHM") {
lat <- 51.49
lon <- -0.17
}
if (input$loc == "York") {
lat <- 53.95
lon <- -1.10
}
if (input$loc == "Houndwood") {
lat <- 55.87
lon <- -2.25
}
if (input$loc == "Lyme Regis") {
lat <- 50.725
lon <- -2.940
}
if (input$loc == "Rovaniemi") {
lat <- 66.5
lon <- 25.733333
}
if (input$loc == "Austin") {
lat <- 30.267222
lon <- -97.743056
}
if (input$loc == "Sydney") {
lat <- -33.867778
lon <- 151.21
}
if (input$display == "Main") {
inner <- 0
outer <- 2
}
if (input$display == "Core") {
inner <- 0
outer <- 1
}
if (input$display == "Ring") {
inner <- 1.75
outer <- 2
}
dielPlot(as.POSIXct(input$date),
lat,
lon,
c(inner, outer),
input$times,
legend=input$legend)
})
}
# Run the application
shinyApp(ui = ui, server = server)