-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.R
More file actions
251 lines (212 loc) · 7.38 KB
/
ui.R
File metadata and controls
251 lines (212 loc) · 7.38 KB
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
# Download all packages: The first time is going to take time
source("check_packages.R")
#load required packages
library(plotly)
library(shiny)
library(shinycssloaders)
# for spinners 2-3 match the background color of wellPanel
options(spinner.color.background="#F5F5F5")
# Custom user friendly error css
css <- "
.shiny-output-error { visibility: hidden; }
.shiny-output-error:before {
visibility: visible;
content: 'An error occurred. Please check your input data for validation.'; }
}"
# Define UI for application
shinyUI(
tagList(
#initialize css
tags$style(type="text/css", css),
navbarPage(
"CVD Risk App",
tabPanel(
# put the title on input tab
"Individual Risk",
sidebarPanel(style = "overflow-y:scroll; max-height: 550px",
# persone name input text
textInput("name", "Name:", "_"),
# numeric input for age
numericInput("age", "Age:", 30, min = 30, max = 74),
# gender option button
radioButtons(
"gender",
"Gender:",
choices = c("Male" = "M", "Female" = "F"),
selected = "M" #set default to Male
),
# sbp numeric input
numericInput(
"sbp",
"Systolic blood pressure:",
90,
min = 90,
max = 200
),
# SBP under treatment option button
radioButtons(
"isSbpTreated",
"is SBP under treatment:",
choices = c("NO" = FALSE, "YES" = TRUE),
selected = FALSE #set default to no sbp treated
),
# Smoking option button
radioButtons(
"smoking_status",
"Smoking:",
choices = c("NO" = FALSE, "YES" = TRUE),
selected = FALSE #set default to no smoking
),
# diabetes option button
radioButtons(
"diabetes_status",
"Diabetic:",
choices = c("NO" = FALSE, "YES" = TRUE),
selected = FALSE #set default to no diabetes
),
tabsetPanel( id = "bmiTab",
# tab panel for bmi
tabPanel("BMI", value="bmi", numericInput(
"bmi", "BMI:", 15, min = 15, max = 50
)),
# tab panel for non-bmi
tabPanel(
"None-BMI", value="nonBmi",
numericInput("hdl", "HDL:", 10, min = 10, max = 100),
numericInput(
"cholesterol",
"Total Cholesterol:",
100,
min = 100,
max = 405
)
)
)
),
mainPanel(
tabsetPanel(
tabPanel(
"Result",
# plot the radar plot
fluidRow(withSpinner(
plotOutput("cvdRadarPlot"),
type = 4
),
textOutput("cvdOneText")
)
),
tabPanel(
"Data",
# plot data
fluidRow(withSpinner(
tableOutput("cvdOneTable"),
type = 4
)
# Display output text
)
)
)
)
),
tabPanel(
"Population Risk",
sidebarPanel(
tabsetPanel( id = "populationTab",
# slider for sample size
tabPanel("Simulation", value="simulation",
sliderInput("sample_size", "Sample Size:", 1, 500, 50)
),
# upload panel for csv
tabPanel(
"Upload Data", value="upload",
fileInput('file1', 'Choose CSV File',
accept=c('text/csv', 'text/comma-separated-values,text/plain', '.csv'))
,
tags$hr(),
# header checkbox
checkboxInput('header', 'Header', TRUE),
# set separators
radioButtons('sep', 'Separator',
c(Comma=',',
Semicolon=';',
Tab='\t'),
','),
# Set quotation marks
radioButtons('quote', 'Quote',
c(None='',
'Double Quote'='"',
'Single Quote'="'"),
'"')
)
)
),
mainPanel(
tabsetPanel(
tabPanel(
"Visualization",
# plot 3d plot of population
fluidRow(withSpinner(
plotlyOutput("cvdPopulationPlot"),
type = 4
))
),
tabPanel("Data Table",
# plot the data table
fluidRow(withSpinner(
dataTableOutput(outputId = 'cvdPopulationDT'),
type = 4
))
)
)
)
),
# Tab about the app and authors
tabPanel("About",
h3(" Introduction:"),
(" CVD Risk App is a shiny app that utilize "),
tags$a(href = "https://github.com/PHP2560-Statistical-Programming-R/r-framingham",
"frisk R package "),
("to estimate projected 10 years Cardiovascular Diseases(CVD) risk
based on"),
tags$a(href = "https://www.framinghamheartstudy.org/risk-functions/cardiovascular-disease/10-year-risk.php",
"Framingham Heart study"),
tags$a(href = "http://circ.ahajournals.org/content/117/6/743.long", "published"),
( "by Ralph B. D’Agostino e all in 2008." ),
br(),
h3(" Usage: "),
( "This App can be used by statistician or physicianes without the need for any R expertise to do:"),
br(),
("1. Survival analysis"),
br(),
("2. Time series"),
br(),
("3. Risk prediction"),
br(),
(" Also could be used by any person to calculate his personal risk and know which risk factors contribute to his CAD 10 risk."),
br(),
h3("Guide"),
h4("1. Individual risk Calculator:"),
img(src='1.png', align = "center",width=650,
height= 550),
img(src='2.png', align = "center",width=650,
height= 180),
br(),
h4("2. population risk Calculator and grapher:"),
img(src='3.png', align = "center",width=650,
height= 550),
br(),
( "PS: Upload data function still under development."),
br(),
h3("Contributors:"),
tags$a( href = "https://github.com/Nour-Audi" ,"@Nour Audi"),
tags$a( href = "https://github.com/kimaina", "@Allan Kimaina"),
tags$a( href = "https://github.com/ilbsm7", "@Triet Tran " ),
h3("Supervisor:"),
tags$a( href = "http://sullivanstatistics.com/", "@Professor Sullivan " ),
h3("License:"),
(" This shiny is licensed under"),
tags$a( href = "https://tldrlegal.com/license/mit-license#fulltext", "MIT License")
)
)
)
)