File: ui.R

package info (click to toggle)
r-cran-rlumshiny 0.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,332 kB
  • sloc: javascript: 922; makefile: 2
file content (284 lines) | stat: -rw-r--r-- 21,485 bytes parent folder | download
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
function(request) {
  fluidPage(
    titlePanel(NULL, windowTitle = "RLumShiny - Histogram"),
    sidebarLayout(
      sidebarPanel(width = 5,

                   # include a tabs in the input panel for easier navigation
                   tabsetPanel(id = "tabs", type = "pill", selected = "Data",
                               # Tab 1: Data input
                               tabPanel("Data",
                                        # informational text
                                        div(align = "center", h5("Data upload")),
                                        # file upload button (data set 1)
                                        fileInput(inputId = "file1",
                                                  label = strong("Primary data set"),
                                                  accept="text/plain, .csv, text/csv"),
                                        # rhandsontable input/output
                                        fluidRow(
                                          column(width = 6,
                                            rHandsontableOutput(outputId = "table_in_primary")
                                        ),
                                          column(width = 6)
                                        ),
                                        hr(),
                                        actionButton(inputId = "refresh", label = "Refresh", icon = icon("fas fa-sync")),
                                        tooltip(refId = "refresh", text = "Redraw the plot")
                               ),##EndOf::Tab_1

                               # Tab 2: Statistical information
                               tabPanel("Statistics",
                                        fluidRow(
                                          column(width = 6,
                                                 checkboxInput(inputId = "summary",
                                                               label = "Show summary",
                                                               value = FALSE),
                                                 tooltip(refId = "summary", text = "Adds numerical output to the plot")
                                          ),
                                          column(width = 6,
                                                 selectInput(inputId = "sumpos",
                                                             label = "Summary position",
                                                             selected = "topleft",
                                                             choices = list("Subtitle" = "sub",
                                                                            "Center" = "center",
                                                                            Top=c("Top" = "top",
                                                                                  "Top left" = "topleft",
                                                                                  "Top right"= "topright"),
                                                                            Bottom=c("Bottom" = "bottom",
                                                                                     "Bottom left" = "bottomleft",
                                                                                     "Bottom right" = "bottomright")
                                                             )),
                                                 tooltip(refId = "sumpos", attr = "for", text = "Position of the statistical summary. The keyword \"Subtitle\" will only work if no plot subtitle is used.")
                                          )
                                        ),

                                        ## ARG 'SUMMARY.METHOD' NOT YET IMPLEMENTED
                                        ##
                                        # selectInput(inputId = "summary.method",
                                        #             label = "Summary method",
                                        #             selected = "unweighted",
                                        #             choices = list("Unweighted" = "unweighted",
                                        #                            "Weighted" = "weighted",
                                        #                            "Monte Carlo" = "MCM")),
                                        # tooltip(refId = "summary.method", attr = "for", text = "Keyword indicating the method used to calculate the statistic summary. See calc_Statistics for details."),

                                        checkboxGroupInput(inputId = "stats",
                                                           label = "Parameters",
                                                           selected = c("n","mean"),
                                                           choices = c("n" = "n",
                                                                       "Mean" = "mean",
                                                                       "Median" = "median",
                                                                       "rel. Standard deviation" = "sdrel",
                                                                       "abs. Standard deviation" = "sdabs",
                                                                       "rel. Standard error" = "serel",
                                                                       "abs. Standard error" = "seabs",
                                                                       "Skewness" = "skewness",
                                                                       "Kurtosis" = "kurtosis"
                                                                       # "% in 2 sigma range" = "in.2s"
                                                           )
                                        ),
                                        tooltip(refId = "stats", text = "Statistical parameters to be shown in the summary"),
                                        div(align = "center", h5("Error bars")),
                                        checkboxInput(inputId = "errorBars",
                                                      label = "Show standard error points",
                                                      value = TRUE),
                                        tooltip(refId = "errorBars", text = "Plot the standard error points over the histogram.")
                               ),##EndOf::Tab_2

                               # Tab 1: Data input
                               tabPanel("Plot",
                                        div(align = "center", h5("Title")),
                                        fluidRow(
                                          column(width = 6,
                                                 textInput(inputId = "main",
                                                           label = "Title",
                                                           value = "Histogram")
                                          ),
                                          column(width = 6,
                                                 textInput(inputId = "mtext",
                                                           label = "Subtitle",
                                                           value = "")
                                          )
                                        ),
                                        div(align = "center", h5("Histogram bars")),
                                        fluidRow(
                                          column(width = 6,
                                                 selectInput(inputId = "barsColor", label = "Bar color",
                                                             selected = "grey80",
                                                             choices = list("White" = "white",
                                                                            "Black" = "black",
                                                                            "Grey" = "grey80",
                                                                            "Red" = "#b22222",
                                                                            "Green" = "#6E8B3D",
                                                                            "Blue" = "#428bca",
                                                                            "Custom" = "custom"))
                                          ),
                                          column(width = 6,
                                                 # show only if custom color is desired
                                                 conditionalPanel(condition = "input.barsColor == 'custom'",
                                                                  jscolorInput(inputId = "barsRgb",
                                                                               label = "Choose a color"))
                                          )
                                        ),
                                        sliderInput(inputId = "alpha.bars",
                                                    label = "Bar transparency",
                                                    min = 0, max = 100,
                                                    step = 1, value = 66),
                                        br(),
                                        div(align = "center", h5("Normal curve")),
                                        checkboxInput(inputId = "norm",
                                                      label = "Add normal curve",
                                                      value = FALSE),
                                        tooltip(refId = "norm", text = "Add a normal curve to the histogram. Mean and standard deviation are calculated from the input data. If the normal curve is added, the y-axis in the histogram will show the probability density"),
                                        fluidRow(
                                          column(width = 6,
                                                 selectInput(inputId = "normalColor", label = "Normal curve color",
                                                             selected = "red",
                                                             choices = list("Black" = "black",
                                                                            "Grey" = "grey50",
                                                                            "Red" = "#b22222",
                                                                            "Green" = "#6E8B3D",
                                                                            "Blue" = "#428bca",
                                                                            "Custom" = "custom"))
                                          ),
                                          column(width = 6,
                                                 # show only if custom color is desired
                                                 conditionalPanel(condition = "input.normalColor == 'custom'",
                                                                  jscolorInput(inputId = "normalRgb",
                                                                               label = "Choose a color"))
                                          )
                                        ),
                                        div(align = "center", h5("Scaling")),
                                        sliderInput(inputId = "cex",
                                                    label = "Scaling factor",
                                                    min = 0.5, max = 2,
                                                    value = 1.0, step = 0.1),
                                        br(),
                                        div(align = "center", h5("Rugs")),
                                        checkboxInput(inputId = "rugs",
                                                      label = "Add rugs",
                                                      value = TRUE),
                                        tooltip(refId = "rugs", text = "Option to add a rug to the KDE part, to indicate the location of individual values"),
                                        fluidRow(
                                          column(width = 6,
                                                 selectInput(inputId = "rugsColor", label = "Rugs color",
                                                             choices = list("Black" = "black",
                                                                            "Grey" = "grey50",
                                                                            "Red" = "#b22222",
                                                                            "Green" = "#6E8B3D",
                                                                            "Blue" = "#428bca",
                                                                            "Custom" = "custom"))
                                          ),
                                          column(width = 6,
                                                 # show only if custom color is desired
                                                 conditionalPanel(condition = "input.rugsColor == 'custom'",
                                                                  jscolorInput(inputId = "rugsRgb",
                                                                               label = "Choose a color"))
                                          )
                                        )
                               ),##EndOf::Tab_9

                               # Tab 4: modify axis parameters
                               tabPanel("Axis",
                                        div(align = "center", h5("X-axis")),
                                        textInput(inputId = "xlab",
                                                  label = "Label x-axis",
                                                  value = "Equivalent dose [Gy]"),
                                        # inject sliderInput from Server.R
                                        uiOutput(outputId = "xlim"),
                                        div(align = "center", h5("Y-axis")),
                                        fluidRow(
                                          column(width = 6,
                                                 textInput(inputId = "ylab1",
                                                           label = "Label y-axis (left)",
                                                           value = "Counts")
                                          ),
                                          column(width = 6,
                                                 textInput(inputId = "ylab2",
                                                           label = "Label y-axis (right)",
                                                           value = "Error")
                                          )
                                        )
                               ),##EndOf::Tab_4

                               # Tab 5: modify data point representation
                               tabPanel("Datapoints",
                                        div(align = "center", h5("Primary data set")),
                                        fluidRow(
                                          column(width = 6,
                                                 selectInput(inputId = "pch",
                                                             label = "Style",
                                                             selected = "17",
                                                             choices = c("Square"= "1",
                                                                         "Circle"="2",
                                                                         "Triangle point up"="3",
                                                                         "Plus"="4",
                                                                         "Cross"="5",
                                                                         "Diamond"="6",
                                                                         "Triangle point down"="7",
                                                                         "Square cross"="8",
                                                                         "Star"="9",
                                                                         "Diamond plus"="10",
                                                                         "Circle plus"="11",
                                                                         "Triangles up and down"="12",
                                                                         "Square plus"="13",
                                                                         "Circle cross"="14",
                                                                         "Square and Triangle down"="15",
                                                                         "filled Square"="16",
                                                                         "filled Circle"="17",
                                                                         "filled Triangle point up"="18",
                                                                         "filled Diamond"="19",
                                                                         "solid Circle"="20",
                                                                         "Bullet (smaller Circle)"="21",
                                                                         "Custom"="custom"))
                                          ),
                                          column(width = 6,
                                                 # show only if custom symbol is desired
                                                 conditionalPanel(condition = "input.pch == 'custom'",
                                                                  textInput(inputId = "custompch",
                                                                            label = "Insert character",
                                                                            value = "?"))
                                          )
                                        ),
                                        fluidRow(
                                          column(width = 6,
                                                 selectInput(inputId = "pchColor", label = "Datapoint color",
                                                             choices = list("Black" = "black",
                                                                            "Grey" = "grey50",
                                                                            "Red" = "#b22222",
                                                                            "Green" = "#6E8B3D",
                                                                            "Blue" = "#428bca",
                                                                            "Custom" = "custom"))
                                          ),
                                          column(width = 6,
                                                 # show only if custom color is desired
                                                 conditionalPanel(condition = "input.pchColor == 'custom'",
                                                                  jscolorInput(inputId = "pchRgb",
                                                                               label = "Choose a color"))
                                          )
                                        )
                               ),##EndOf::Tab_5
                               RLumShiny:::exportTab("export", filename = "histogram"),
                               RLumShiny:::aboutTab("about", "histogram")
                   )##EndOf::tabsetPanel
      ),##EndOf::sidebarPanel


      # 3 - output panel
      mainPanel(width = 7,
                # insert css code inside <head></head> of the generated HTML file:
                # allow open dropdown menus to reach over the container
                tags$head(tags$style(type="text/css",".tab-content {overflow: visible;}")),
                tags$head(includeCSS("www/style.css")),
                # divide output in separate tabs via tabsetPanel
                tabsetPanel(
                  tabPanel("Plot", plotOutput(outputId = "main_plot", height = "500px")),
                  tabPanel("Data set", dataTableOutput("dataset")),
                  tabPanel("Central Age Model", dataTableOutput("CAM")),
                  tabPanel("R plot code", verbatimTextOutput("plotCode"))
                )###EndOf::tabsetPanel
      )##EndOf::mainPanel
    ),##EndOf::sideBarLayout
    bookmarkButton()
  )##EndOf::fluidPage
}