]> nmode's Git Repositories - Rnaught/blob - R/ui.R
8a82158f5feffc7d5c5800048b7d24b8092ea186
[Rnaught] / R / ui.R
1 ui <- function() { shiny::fluidPage(
2 # Title.
3 shiny::titlePanel(shiny::HTML(
4 paste0("Rnaught: An Estimation Suite for R", shiny::tags$sub("0")))),
5 # Sidebar layout.
6 shiny::sidebarLayout(
7 # Sidebar. Hidden if the 'About' tab is selected.
8 shiny::conditionalPanel(condition = "input.tabset != 'About'",
9 shiny::sidebarPanel(id = "sidebar",
10 # Data tab sidebar.
11 shiny::conditionalPanel(condition = "input.tabset == 'Data'",
12 shiny::h3("Enter data"),
13 # Data input method selection.
14 shiny::radioButtons(inputId = "dataInputMethod", label = "",
15 choices=list("Manually" = 1, "Upload a .csv file" = 2,
16 "Paste a .csv file" = 3)),
17 # Option 1: Manual entry.
18 shiny::conditionalPanel(condition = "input.dataInputMethod == '1'",
19 shiny::textInput(inputId = "dataName", label = "Dataset name"),
20 shiny::span(shiny::textOutput(outputId = "dataNameWarn"),
21 style = "color: red;"),
22 shiny::fluidRow(
23 shiny::column(8,
24 shiny::textInput(inputId = "dataCounts", label = shiny::HTML(
25 paste0("Case counts", shiny::tags$sup("[?]",
26 title = paste0("Enter as a comma-separated list of ",
27 "positive integers, with at least two ",
28 "entries. Example: 1,1,2,3,5,8")))))),
29 shiny::column(4,
30 shiny::selectInput(inputId = "dataUnits",
31 label = "Reporting frequency",
32 choices = list("Daily", "Weekly")))
33 ),
34 shiny::span(shiny::textOutput(outputId = "dataCountsWarn"),
35 style = "color: red;")
36 ),
37 # Option 2: Upload .csv file.
38 shiny::conditionalPanel(condition = "input.dataInputMethod == '2'",
39 shiny::fileInput(inputId = "dataUpload", label = "",
40 accept = c("text/csv", "text/comma-separated-values,text/plain",
41 ".csv")),
42 ),
43 # Option 3: Paste .csv file.
44 shiny::conditionalPanel(condition = "input.dataInputMethod == '3'",
45 shiny::textAreaInput(inputId = "dataPaste", label = "",
46 rows = 8, resize = "none"),
47 ),
48 # Warning text for .csv upload / paste.
49 shiny::conditionalPanel(
50 condition = "['2', '3'].includes(input.dataInputMethod)",
51 shiny::span(shiny::textOutput(outputId = "dataCSVWarn"),
52 style = "color: red;"),
53 ),
54 # Button to add data.
55 shiny::actionButton(inputId = "addData", label = "Add"),
56 ),
57 # Estimators tab sidebar (collapsable entries).
58 shiny::conditionalPanel(condition = "input.tabset == 'Estimators'",
59 shiny::h3("Estimators"),
60 # WHITE & PANAGO (WP).
61 shiny::tags$details(
62 shiny::tags$summary(shiny::h4("White & Panago (WP)")),
63 shiny::p("Method due to White and Pagano (2008), assumes a branching process based model. Serial
64 distribution can be assumed known or can be estimated using maximum likelihood; When serial interval is unknown
65 the method takes longer to compute, though is still real-time."),
66 shiny::br(),
67 shiny::radioButtons(inputId = "serialWPKnown",
68 label = "Is the mean serial interval known?",
69 inline = TRUE,
70 choices = list("Yes" = 1, "No" = 2)),
71 # Known serial interval.
72 shiny::conditionalPanel(condition = "input.serialWPKnown == '1'",
73 shiny::fluidRow(
74 shiny::column(8,
75 shiny::textInput(inputId = "serialWPInput",
76 label = "Mean Serial Interval")),
77 shiny::column(4,
78 shiny::selectInput(inputId = "serialWPUnits",
79 label = "Time units",
80 choices = list("Days", "Weeks")))
81 ),
82 shiny::span(shiny::textOutput(outputId = "serialWPWarn"),
83 style = "color: red;")
84 ),
85 # Unknown serial interval.
86 shiny::conditionalPanel(condition = "input.serialWPKnown == '2'",
87 shiny::h5("Grid Search Parameters"),
88 shiny::fluidRow(
89 shiny::column(4,
90 shiny::textInput(inputId = "gridLengthInput",
91 label = "Grid length", value = "100")),
92 shiny::column(4,
93 shiny::textInput(inputId = "gridShapeInput",
94 label = "Max. shape", value = "10")),
95 shiny::column(4,
96 shiny::textInput(inputId = "gridScaleInput",
97 label = "Max. scale", value = "10"))
98 ),
99 shiny::fluidRow(
100 shiny::column(4,
101 shiny::span(shiny::textOutput(outputId = "gridLengthWarn"),
102 style = "color: red;")),
103 shiny::column(4,
104 shiny::span(shiny::textOutput(outputId = "gridShapeWarn"),
105 style = "color: red;")),
106 shiny::column(4,
107 shiny::span(shiny::textOutput(outputId = "gridScaleWarn"),
108 style = "color: red;"))
109 )
110 ),
111 shiny::actionButton(inputId = "addWP", label = "Add")
112 ),
113 # SEQUENTIAL BAYES (seqB).
114 shiny::tags$details(
115 shiny::tags$summary(shiny::h4("Sequential Bayes (seqB)")),
116 shiny::p("This is a description of the method."),
117 shiny::br(),
118 shiny::fluidRow(
119 shiny::column(8,
120 shiny::textInput(inputId = "serialseqBInput",
121 label = "Mean Serial Interval")),
122 shiny::column(4,
123 shiny::selectInput(inputId = "serialseqBUnits",
124 label = "Time units",
125 choices = list("Days", "Weeks")))
126 ),
127 shiny::span(shiny::textOutput(outputId = "serialseqBWarn"),
128 style = "color: red;"),
129 shiny::textInput(inputId = "kappaInput",
130 label = shiny::HTML(paste0("Maximum value", shiny::tags$sup("[?]",
131 title = paste0("This describes the prior belief of R0, and ",
132 "should be set to a higher value if R0 is ",
133 "believed to be larger. (Default: 20)")))),
134 value = "20"),
135 shiny::span(shiny::textOutput(outputId = "kappaWarn"),
136 style = "color: red;"),
137 shiny::actionButton(inputId = "addseqB", label = "Add")
138 ),
139 # INCIDENCE DECAY (ID).
140 shiny::tags$details(
141 shiny::tags$summary(shiny::h4("Incidence Decay (ID)")),
142 shiny::p("This is a description of the method."),
143 shiny::br(),
144 shiny::fluidRow(
145 shiny::column(8,
146 shiny::textInput(inputId = "serialIDInput",
147 label = "Mean Serial Interval")),
148 shiny::column(4,
149 shiny::selectInput(inputId = "serialIDUnits",
150 label = "Time units",
151 choices = list("Days", "Weeks")))
152 ),
153 shiny::span(shiny::textOutput(outputId = "serialIDWarn"),
154 style = "color: red;"),
155 shiny::actionButton(inputId = "addID", label = "Add")
156 ),
157 # INCIDENCE DECAY & EXPONENTIAL ADJUSTEMENT (IDEA).
158 shiny::tags$details(
159 shiny::tags$summary(
160 shiny::h4("Incidence Decay and Exponential Adjustement (IDEA)")),
161 shiny::p("This is a description of the method."),
162 shiny::br(),
163 shiny::fluidRow(
164 shiny::column(8,
165 shiny::textInput(inputId = "serialIDEAInput",
166 label = "Mean Serial Interval")),
167 shiny::column(4,
168 shiny::selectInput(inputId = "serialIDEAUnits",
169 label = "Time units",
170 choices = list("Days", "Weeks")))
171 ),
172 shiny::span(shiny::textOutput(outputId = "serialIDEAWarn"),
173 style = "color: red;"),
174 shiny::actionButton(inputId = "addIDEA", label = "Add")
175 ),
176 shiny::tags$style(type = "text/css",
177 "summary { display: list-item; cursor: pointer; }"),
178 shiny::tags$style(type = "text/css",
179 "summary h4 { display: inline; }")
180 )
181 )
182 ),
183 # Main panel.
184 shiny::mainPanel(id = "main",
185 shiny::tabsetPanel(id = "tabset", type = "tabs",
186 shiny::tabPanel("About", shiny::br(), "Hello"),
187 shiny::tabPanel("Data", shiny::br(),
188 shiny::dataTableOutput(outputId = "dataTable"),
189 shiny::tags$style(type = "text/css",
190 "#dataTable tfoot { display:none; }")),
191 shiny::tabPanel("Estimators", shiny::br(),
192 shiny::dataTableOutput(outputId = "estTable"),
193 shiny::tags$style(type = "text/css",
194 "#estTable tfoot { display:none; }"),
195 shiny::downloadButton(outputId = "downloadEst",
196 label = "Download table as .csv"))
197 )
198 )
199 )
200 )}