]>
nmode's Git Repositories - Rnaught/blob - R/ui.R
4 shiny
::titlePanel(shiny
::HTML(
5 paste0("Rnaught: An Estimation Suite for R", shiny
::tags$
sub("0")))),
8 # Sidebar. Hidden if the 'About' tab is selected.
9 shiny
::conditionalPanel(condition
= "input.tabset != 'About'",
10 shiny
::sidebarPanel(id
= "sidebar", data_sidebar(), est_sidebar())),
12 shiny
::mainPanel(id
= "main",
13 shiny
::tabsetPanel(id
= "tabset", type
= "tabs",
14 shiny
::tabPanel("About", shiny
::br(), "Hello"),
15 shiny
::tabPanel("Data", shiny
::br(),
16 shiny
::dataTableOutput(outputId
= "dataTable"),
17 shiny
::tags$
style(type
= "text/css",
18 "#dataTable tfoot { display:none; }")),
19 shiny
::tabPanel("Estimators", shiny
::br(),
20 shiny
::dataTableOutput(outputId
= "estTable"),
21 shiny
::tags$
style(type
= "text/css",
22 "#estTable tfoot { display:none; }"),
23 shiny
::downloadButton(outputId
= "downloadEst",
24 label
= "Download table as .csv"))
32 data_sidebar
<- function() {
33 shiny
::conditionalPanel(condition
= "input.tabset == 'Data'",
34 shiny
::h3("Enter data"),
35 # Data input method selection.
36 shiny
::radioButtons(inputId
= "dataInputMethod", label
= "",
37 choices
=list("Manually" = 1, "Upload a .csv file" = 2,
38 "Paste a .csv file" = 3)),
39 # Option 1: Manual entry.
40 shiny
::conditionalPanel(condition
= "input.dataInputMethod == '1'",
41 shiny
::textInput(inputId
= "dataName", label
= "Dataset name"),
42 shiny
::span(shiny
::textOutput(outputId
= "dataNameWarn"),
43 style
= "color: red;"),
46 shiny
::textInput(inputId
= "dataCounts",
47 label
= help_tool("Case counts", paste0("Enter as a ",
48 "comma-separated list of positive integers, with at least two ",
49 "entries. (Example: 1,1,2,3,5,8)")))),
50 shiny
::column(4, shiny
::selectInput(inputId
= "dataUnits",
51 label
= "Reporting frequency", choices
= list("Daily", "Weekly")))
53 shiny
::span(shiny
::textOutput(outputId
= "dataCountsWarn"),
54 style
= "color: red;")
56 # Option 2: Upload .csv file.
57 shiny
::conditionalPanel(condition
= "input.dataInputMethod == '2'",
58 shiny
::fileInput(inputId
= "dataUpload", label
= "",
59 accept
= c("text/csv", "text/comma-separated-values,text/plain",
62 # Option 3: Paste .csv file.
63 shiny
::conditionalPanel(condition
= "input.dataInputMethod == '3'",
64 shiny
::textAreaInput(inputId
= "dataPaste", label
= "",
65 rows
= 8, resize
= "none"),
67 # Warning text for .csv upload / paste.
68 shiny
::conditionalPanel(
69 condition
= "['2', '3'].includes(input.dataInputMethod)",
70 shiny
::span(shiny
::textOutput(outputId
= "dataCSVWarn"),
71 style
= "color: red;"),
74 shiny
::actionButton(inputId
= "addData", label
= "Add")
78 # Estimators tab sidebar.
79 est_sidebar
<- function() {
80 shiny
::conditionalPanel(condition
= "input.tabset == 'Estimators'",
81 shiny
::h3("Estimators"),
87 shiny
::tags$
style(type
= "text/css",
88 "summary { display: list-item; cursor: pointer; }"),
89 shiny
::tags$
style(type
= "text/css", "summary h4 { display: inline; }")
93 # Collapsable entry for White & Panago (WP) method.
94 WP_collapse
<- function() {
96 shiny
::tags$
summary(shiny
::h4("White & Panago (WP)")),
97 shiny
::p("Method due to White and Pagano (2008), assumes a branching process
98 based model. Serial distribution can be assumed known or can be
99 estimated using maximum likelihood; When serial interval is
100 unknown the method takes longer to compute, though is still
103 shiny
::radioButtons(inputId
= "serialWPKnown",
104 label
= "Is the mean serial interval known?",
105 inline
= TRUE, choices
= list("Yes" = 1, "No" = 2)),
106 # Known serial interval.
107 shiny
::conditionalPanel(condition
= "input.serialWPKnown == '1'",
108 serial_fields("WP")),
109 # Unknown serial interval.
110 shiny
::conditionalPanel(condition
= "input.serialWPKnown == '2'",
111 shiny
::h5("Grid Search Parameters"),
113 shiny
::column(4, shiny
::textInput(inputId
= "gridLengthInput",
114 label
= "Grid length", value
= "100")),
115 shiny
::column(4, shiny
::textInput(inputId
= "gridShapeInput",
116 label
= "Max. shape", value
= "10")),
117 shiny
::column(4, shiny
::textInput(inputId
= "gridScaleInput",
118 label
= "Max. scale", value
= "10"))
121 shiny
::column(4, shiny
::span(shiny
::textOutput(
122 outputId
= "gridLengthWarn"), style
= "color: red;")),
123 shiny
::column(4, shiny
::span(shiny
::textOutput(
124 outputId
= "gridShapeWarn"), style
= "color: red;")),
125 shiny
::column(4, shiny
::span(shiny
::textOutput(
126 outputId
= "gridScaleWarn"), style
= "color: red;"))
129 shiny
::actionButton(inputId
= "addWP", label
= "Add")
133 # Collapsable entry for Sequential Bayes (seqB) method.
134 seqB_collapse
<- function() {
136 shiny
::tags$
summary(shiny
::h4("Sequential Bayes (seqB)")),
137 shiny
::p("This is a description of the method."),
139 serial_fields("seqB"),
140 shiny
::textInput(inputId
= "kappaInput",
141 label
= help_tool("Maximum value", paste0("This describes the prior ",
142 "belief of R0, and should be set to a higher value if R0 is believed ",
143 "be larger. (Default: 20)")), value
= "20"),
144 shiny
::span(shiny
::textOutput(outputId
= "kappaWarn"),
145 style
= "color: red;"),
146 shiny
::actionButton(inputId
= "addseqB", label
= "Add")
150 # Collapsable entry for Incidence Decay (ID) method.
151 ID_collapse
<- function() {
153 shiny
::tags$
summary(shiny
::h4("Incidence Decay (ID)")),
154 shiny
::p("This is a description of the method."),
157 shiny
::actionButton(inputId
= "addID", label
= "Add")
161 # Collapsable entry for Incidence Decay & Exponential Adjustment (IDEA) method.
162 IDEA_collapse
<- function() {
165 shiny
::h4("Incidence Decay and Exponential Adjustment (IDEA)")),
166 shiny
::p("This is a description of the method."),
168 serial_fields("IDEA"),
169 shiny
::actionButton(inputId
= "addIDEA", label
= "Add")
173 # Input fields and warning text for the mean serial interval.
174 serial_fields
<- function(method
) {
177 shiny
::column(8, shiny
::textInput(
178 inputId
= paste0("serial", method
, "Input"),
179 label
= "Mean Serial Interval")),
180 shiny
::column(4, shiny
::selectInput(
181 inputId
= paste0("serial", method
, "Units"),
182 label
= "Time units", choices
= list("Days", "Weeks")))
184 shiny
::span(shiny
::textOutput(outputId
= paste0("serial", method
, "Warn")),
185 style
= "color: red;")
189 # Display help information on hover.
190 help_tool
<- function(label
, help_text
) {
191 shiny
::HTML(paste0(label
, shiny
::tags$
sup("[?]", title
= help_text
)))