-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathui.R
412 lines (407 loc) · 17.3 KB
/
ui.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
list.of.packages <- c("shiny","rmarkdown","markdown","dplR",
"shinyWidgets","DT","shinyjs","plotly",
"tidyverse","RColorBrewer","kableExtra")
#checking missing packages from list
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
#install missing ones
if(length(new.packages)) install.packages(new.packages, dependencies = TRUE)
library(shiny)
library(markdown)
library(rmarkdown)
library(dplR)
library(DT)
library(shinyjs)
library(shinyWidgets)
library(plotly)
library(tidyverse)
library(RColorBrewer)
library(kableExtra)
ui <- tagList(
useShinyjs(),
tags$head(
tags$style(HTML("hr {border-top: 1px solid #000000;}"))
),
navbarPage(
title = "xDateR",
id = "navbar",
# start tabs
# 1st tab Introduction and Upload ----
tabPanel(title="1. Introduction and Upload",value="IntroTab",
sidebarLayout(
# Sidebar panel for inputs
sidebarPanel(
h5("Upload RWL"),
includeMarkdown("text_upload.rmd"),
hr(),
h5("Dated Series"),
fileInput(inputId="file1",
label=NULL,
multiple = FALSE,
accept = c("text/plain",
".rwl",
".raw",
".txt")),
checkboxInput(inputId="useDemoDated", label="Or use example data",
value=FALSE),
shinyjs::hidden(div(id='divUndated',
hr(),
h5("Undated Series (Optional)"),
fileInput(inputId="file2",
label=NULL,
multiple = FALSE,
accept = c("text/plain",
".rwl",
".raw",
".txt")),
checkboxInput(inputId="useDemoUndated", label="Or use example data",
value=FALSE)
))
),
# Main panel for displaying outputs
mainPanel(
includeMarkdown("text_intro.rmd")
)
)
),
# 2nd tab Describe RWL Data ----
tabPanel(title="2. Describe RWL Data",value="DescribeTab",
# Sidebar layout with input and output definitions
includeMarkdown("text_describe.rmd"),
hr(),
plotOutput("rwlPlot"),
selectInput(inputId="rwlPlotType", label="Plot Type",
choices=c("seg","spag"),
selected = "seg"),
hr(),
h5("RWL Report"),
verbatimTextOutput("rwlReport"),
hr(),
h5("Series Summary"),
tableOutput("rwlSummary"),
hr(),
downloadButton("rwlSummaryReport", "Generate report")
),
# 3rd tab Correlations Between Series ----
tabPanel(title="3. Correlations Between Series", value="AllSeriesTab",
includeMarkdown("text_rwl_correlation.rmd"),
h5("Correlation by Series and Segment"),
# plotOutput("crsPlot"),
# actionButton("launchFancyPlot", "Make Interactive Plot"),
plotlyOutput("crsFancyPlot"),
hr(),
fluidRow(
column(12,align="center",
sliderInput(inputId="seg.lengthCRS",
label="Segment Length",
min = 10,
max = 200,
value = 50,
step=10))
),
fluidRow(
column(4,
awesomeCheckboxGroup(inputId = "master",
inline = TRUE,
label = "Filter series",
choices = c("")),
actionButton(inputId="updateMasterButton",
label="Update",
class = "btn-primary",
style='padding:4px; font-size:100%')
),
column(2,
checkboxInput(inputId="prewhitenCRS", label="Prewhiten",value=TRUE),
checkboxInput(inputId="biweightCRS", label="Biweight",value=TRUE)),
column(3,
selectInput(inputId="nCRS", label="n",
choices=c("NULL", seq(5,13,by=2)),
selected = "NULL"),
selectInput(inputId="bin.floorCRS", label="Bin Floor",
choices=c(0, 10, 50, 100),selected = 10)
),
column(3,
numericInput(inputId="pcritCRS", label="P crit",
value=0.05,min=0,max=1,step=0.01),
selectInput(inputId="methodCRS", label="Method",
choices=c("pearson", "kendall", "spearman"),
selected = "spearman")
)
),
fluidRow(
hr(),
h5("Correlation Overview"),
p("Significant correlations are in bold."),
column(4,
DTOutput("crsOverall")),
column(4,
DTOutput("crsAvgCorrBin")),
column(4,
DTOutput("crsFlags"))
),
fluidRow(
hr(),
h5("Correlation by Series/Segment"),
DTOutput("crsCorrBin")),
hr(),
downloadButton("crsReport", "Generate report")
),
# 4th tab Individual Series Correlations ----
tabPanel(title="4. Individual Series Correlations", value="IndividualSeriesTab",
includeMarkdown("text_series_correlation.rmd"),
hr(),
h5("Flagged Series"),
textOutput("flaggedSeries"),
h5("Series Correlation"),
plotOutput("cssPlot"),
hr(),
fluidRow(
column(4,
selectInput(inputId = "series",
label = "Choose series",
choices = c("foo"))
),
column(8,align="center",
sliderInput(inputId="seg.lengthCSS",
label="Segment Length",
min = 10,
max = 200,
value = 50,
step=10))
),
fluidRow(
column(2),
column(2,
checkboxInput(inputId="prewhitenCSS", label="Prewhiten",value=TRUE),
checkboxInput(inputId="biweightCSS", label="Biweight",value=TRUE)),
column(3,
selectInput(inputId="nCSS", label="n",
choices=c("NULL", seq(5,13,by=2)),
selected = "NULL"),
selectInput(inputId="bin.floorCSS", label="Bin Floor",
choices=c(0, 10, 50, 100),selected = 10)
),
column(3,
numericInput(inputId="pcritCSS", label="P crit",
value=0.05,min=0,max=1,step=0.01),
selectInput(inputId="methodCSS", label="Method",
choices=c("pearson", "kendall", "spearman"),
selected = "spearman")
),
column(2)
),
h5("Series Cross-Correlation by Segment"),
plotOutput("ccfPlot"),
fluidRow(
column(2),
column(4,
numericInput(inputId="lagCCF", label="Max lag",
value=5,min=1,max=100,step=1)
),
column(4,
uiOutput("rangeCCF")
),
column(2)
),
hr(),
textAreaInput(inputId="datingNotes",
label="Dating notes",
value="",width="600px",height = "400px",
placeholder="Notes will be saved if you generate a report."),
hr(),
downloadButton("cssReport", "Generate report")
),
# 5th (a) tab Edit Series ----
tabPanel(title="5. Edit Series",value="EditSeriesTab",
# start row 1 for skel ccf (might need spacer cols?)
h5("Series Cross-Correlation with Skeleton Plot"),
textOutput("series2edit"),
plotOutput("xskelPlot"),
fluidRow(
column(2),
column(4,
uiOutput("winCenter")
),
column(4,
sliderInput(inputId="winWidth",
label="Window width",
value=40,
min=10,
max=80,
step=10)
),
column(2)
), # end row 1
# start row 2
hr(),
# end row 2
fluidRow( # start row 3
column(1), #space
column(5, # col for remove on left
includeMarkdown("text_edit.rmd"),
h5("Remove Row"),
actionButton("deleteRows", "Delete Measurement"),
checkboxInput(inputId="deleteRingFixLast",
label="Fix Last Year",value=TRUE),
helpText("Click \"Delete Measurement\" to delete a year (row).
If \"Fix Last Year\" is selected the last year of
growth will stay the same."),
h5("Add Row"),
numericInput(inputId="insertValue",
label="Measurement Value",
value = 0,
min = 0),
actionButton("insertRows", "Insert Measurement"),
checkboxInput(inputId="insertRingFixLast",
label="Fix Last Year",value=TRUE),
helpText("To add a year, enter a
value and click \"Insert Measurement.\" The new row appears above
the highlight. If \"Fix Last Year\" is selected the
last year of growth will stay the same.")
), # end col for remove row
column(5, # start col for table
dataTableOutput("table1")
), #end col for table
column(1) # space
), #end row 3
# start row 4
hr(),
conditionalPanel(
condition = "output.showSaveEdits == true",
fluidRow(
column(1),
column(3,
h5("Undo Changes"),
actionButton("revertSeries", "Revert Changes")
),
column(7,
h5("Save Edited File"),
downloadButton('downloadRWL', 'Download rwl object (.rwl)'),
helpText("The rwl file is writen in tucson/decadal format readable
by standard dendro programs.(e.g., read.rwl() in
dplR).")
)
),
fluidRow(
column(1),
column(10,
verbatimTextOutput("editLog"),
downloadButton("editReport", "Generate report")
)
)
)
), # end tab
# 5th (b) tab DataEditR Series ----
# this works after a fashion but I'm not sure it will have
# the right functionality for keeping years fixed etc.
# tabPanel(title="5b. Edit Series",value="DataEditRSeriesTab",
# sidebarLayout(
# sidebarPanel(
# includeMarkdown("text_DataEditR.rmd"),
# width=5),
#
# mainPanel(
# textOutput("series2DataEditR"),
# hr(),
# p("The data itself"),
# dataEditUI("edit-1"),
# p("was it there?"),
# width=7)
# )
# ),
# 6th tab Undated Series ----
tabPanel(title="6. Undated Series",value="UndatedSeriesTab",
includeMarkdown("text_undated.rmd"),
hr(),
h5("RWL Report"),
verbatimTextOutput("rwlReport2"),
hr(),
h5("Best Overall Dating for Series"),
plotOutput("floaterPlot"),
fluidRow(
column(1),
column(5,
selectInput(inputId = "series2",
label = "Choose undated series",
choices = c("bar")),
sliderInput(inputId="minOverlapUndated",
label="Minimim Overlap",
value=50,
min=10,
max=200,
step=10)
),
column(2,
checkboxInput(inputId="prewhitenUndated", label="Prewhiten",value=TRUE),
checkboxInput(inputId="biweightUndated", label="Biweight",value=TRUE)),
column(3,
selectInput(inputId="nUndated", label="n",
choices=c("NULL", seq(5,13,by=2)),
selected = "NULL"),
selectInput(inputId="methodUndated", label="Method",
choices=c("pearson", "kendall", "spearman"),
selected = "spearman")
),
column(1)
),
hr(),
plotOutput("ccfPlotUndated"),
fluidRow(
column(2),
column(4,align="center",
sliderInput(inputId="seg.lengthUndated",
label="Segment Length",
min = 10,
max = 200,
value = 50,
step=10)),
column(4,
selectInput(inputId="bin.floorUndated", label="Bin Floor",
choices=c(0, 10, 50, 100),selected = 10),
numericInput(inputId="pcritUndated", label="P crit",
value=0.05,min=0,max=1,step=0.01)
),
column(2)
),
hr(),
fluidRow(
column(1),
column(5,
fluidRow(
h5("Floater Report"),
htmlOutput("floaterText")
),
fluidRow(
hr(),
actionButton("saveDates", "Save Dates"),
actionButton("removeDates", "Revert")
),
fluidRow(
hr(),
h5("Log"),
verbatimTextOutput("dateLog")
)
),
column(5,
textAreaInput(inputId="undatingNotes",
label="Dating notes",
value="",width="600px",height = "400px",
placeholder="Notes will be saved if you generate a report.")
),
column(1)
),
hr(),
h5("Save Dated Series to File"),
downloadButton('downloadUndatedRWL', 'Download dated rwl object (.rwl)'),
checkboxInput(inputId="appendMaster", label="Append dated rwl?",
value=FALSE),
helpText("The rwl file contains any series where dates were assigned above.
The series from the dated (master) rwl
can optionally be included in the output file as well.
The file is writen in tucson/decadal format readable by standard dendro
programs.(e.g., read.rwl() in dplR)."),
hr(),
downloadButton("undatedReport", "Generate report")
)
# end tabs
)
)