-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.R
781 lines (612 loc) · 27.4 KB
/
app.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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
library(shiny)
library(tidyverse)
library(plotly)
library(shinydashboard)
library(lubridate)
library(scales)
#
# Notes on the UI
# Major sections are created by code > "insert section"
# Minor sections have a comment hash and four dashes
# Minor comments just get the comment hash
demographics <- read_rds("./www/mergeddemographics.rds")
dates <- read_rds("./www/dates.rds")
datesgathered <- read_rds("./www/datesgathered.rds")
dlong <- read_rds("./www/dlong.rds")
# Define the UI -----------------------------------------------------------
ui <- dashboardPage(
dashboardHeader(title = "HACSL Dashboard"),
# Make a sidebar with the right tabs ----
dashboardSidebar(
sidebarMenu(
menuItem("Home", tabName = "Home", icon = icon("cog")),
menuItem("Program Overview", tabName = "overview", icon = icon("dashboard")),
menuItem("Client Demographics", tabName = "demographics", icon = icon("th")),
menuItem("Housing and Lease", tabName = "housing", icon = icon("home")),
menuItem("Time to Housing", tabName = "duration", icon = icon("calendar"))#,
# menuItem("Map of Housing", tabName = "map", icon = icon("map-marker"))
)
),
# Start of the actual body ----
dashboardBody(
tags$head(
tags$link(rel = "stylesheet", type = "text/css", href = "dashboard.css")
),
# Tabs begin ----
tabItems(
# Home tab ----
tabItem(tabName = "Home",
fluidRow(
column(12,
img(src="SLC Housing Dashboard.png", class="welcomeImage"),
h3("Welcome to the HACSL DataVis Dashboard", align = "center"),
p("The following dashboard is an at-a-glance informational resource to explore housing placement for
The Housing Authority of the County of Salt Lake. Data presented here are aggregated, de-identified program-level
data from The Housing Authority of the County of Salt Lake. The following funding sources are included in the
information presented: HACSL Continuum of Care and Salt Lake County HARP Program.")
)
)
),
# Overview tab ----
tabItem(tabName = "overview",
fluidRow(
column(12,
h3("Program Overview"),
p("Data presented here are aggregated, de-identified program-level data from The Housing Authority of the
County of Salt Lake. The following funding sources are included in the information presented: HACSL Continuum
of Care and Salt Lake County HARP Program."
)
)
),
br(),
fluidRow(
column(12,
valueBoxOutput("Individuals"),
valueBoxOutput("Families"),
valueBoxOutput("Percent")
)
),
br(),
fluidRow(
column(7,
h4("Individuals Served by Entry Date"),
plotlyOutput("servedbymonth")
),
column(5,
h4("Days to Housing"),
plotlyOutput("Vouchertime")
)
)
),
# Demographics tab ----
tabItem(tabName = "demographics",
fluidRow(
column(12,
p("The following charts and graphs show detailed demographic data for households served by HACSL.")
)
),
# Demographics sliders ----
fluidRow(
column(4,
h4("Demographics:"),
selectInput(
inputId = "clienttype", "Household Composition:",
choice = c("All", unique(as.character(demographics$client_type)))
),
selectInput(
inputId = "gender", "Gender:",
c("All", unique(as.character(demographics$Gender)))
),
selectInput(
inputId = "ethnicity", "Ethnicity:",
c("All", unique(as.character(demographics$Ethnicity)))
),
selectInput(
inputId = "race", "Race:",
c("All", unique(as.character(demographics$Race)))
)
),
column(4,
h4("Number of Households"),
plotlyOutput("clientplot")
),
column(4,
h4("Number of Households by Gender"),
plotlyOutput("client_genderplot")
),
br()
),
# Demographics plots ----
fluidRow(
column(12,
h4("Number of Households Over Time"),
plotlyOutput("client_timeplot")
)
),
br(),
fluidRow(
column(12,
h4("Number of Households by Race"),
plotlyOutput("client_raceplot")
)
),
br(),
fluidRow(
column(12,
h4("Number of Households by Ethnicity"),
plotlyOutput("client_ethnplot")
)
),
br(),
fluidRow(
column(12,
h4("Number of Households by Income Level"),
plotlyOutput("client_incomeplot")
)
),
br(),
fluidRow(
column(12,
h4("Number of Households With X Number of Children"),
plotlyOutput("client_kidplot")
)
)
),
# Housing tab ----
tabItem(tabName = "housing",
fluidRow(
column(12,
p("The following charts and graphs show the detailed housing and lease data for households served by HACSL.")
)
),
# Housing sliders ----
fluidRow(column(3,
h4("Demographics:"),
selectInput(
inputId = "clienttypeh", "Household Composition:",
choice = c("All", unique(as.character(demographics$client_type)))
),
selectInput(
inputId = "genderh", "Gender:",
c("All", unique(as.character(demographics$Gender)))
),
selectInput(
inputId = "ethnicityh", "Ethnicity:",
c("All", unique(as.character(demographics$Ethnicity)))
),
selectInput(
inputId = "raceh", "Race:",
c("All", unique(as.character(demographics$Race)))
)
),
column(9,
h4("Frequency Chart of Total Rent"),
plotlyOutput("rentplot"),
br(),
h4("Frequency Chart of Amount Tenant Pays Toward Rent"),
plotlyOutput("rentbytenantplot"),
br()
)
),
fluidRow(
column(12,
h4("Scatterplot of Rent"),
plotlyOutput("rentscatterplot")
)
),
br(),
fluidRow(
column(12,
h4("Number of Bedrooms"),
plotlyOutput("bedroomsplot")
)
),
br(),
fluidRow(
column(12,
h4("Box Plot of Rent by Bedroom Count"),
p("Each boxplot below shows the distrubtion of the data by bedroom count. The line in the center of the box is the median,
the top line of the boxplot is the third quartile (75th percentile), the bottom line of the boxplot is the first quartile (25th percentile),
the tallest whisker represents 1.5 times the third quartile, and the whiskers are 1.5 times the interquartile range from the top or bottom of
the box to the furthest datum within that distance."),
plotlyOutput("bedroomsrentplot")
)
),
br(),
fluidRow(
column(12,
h4("Box Plot of Rent by Housing Type"),
p("Each boxplot below shows the distrubtion of the data by housing type. The line in the center of the box is the median,
the top line of the boxplot is the third quartile (75th percentile), the bottom line of the boxplot is the first quartile (25th percentile),
the tallest whisker represents 1.5 times the third quartile, and the whiskers are 1.5 times the interquartile range from the top or bottom of
the box to the furthest datum within that distance."),
plotlyOutput("typerentplot")
)
)
),
# Duration tab ----
tabItem(tabName = "duration",
fluidRow(
column(12,
p("The following charts and graphs describe how a person goes from being referred to HACSL
to finally being housed.")
)
),
br(),
fluidRow(
column(12,
h4("Average Number of Days Between Each Step to Housing"),
valueBoxOutput("Vouchertimed"),
valueBoxOutput("Vouchertimedpacket"),
valueBoxOutput("Vouchertimedvoucher")
)
),
br(),
fluidRow(
column(12,
h4("Average Number of Days to Housing"),
valueBoxOutput("Vouchertoleaseup"),
valueBoxOutput("Referraltovouch"),
valueBoxOutput("Referraltoleaseup")
)
),
br(),
fluidRow(
column(12,
h4("Every Household Processed Through HACSL Less than 50 Days"),
plotlyOutput("timeplot")
)
),
br(),
fluidRow(
column(12,
h4("Every Household Processed Through HACSL ALL"),
plotlyOutput("timetwoplot")
)
),
br(),
fluidRow(
column(12,
h4("Days to Complete Each Progress Point by Individuals Indexed by Entry Date"),
p("Each bar represents one individual. Each individual is indexed by the time they enter HACSL's systems.
The individual assigned the first number is the individual with the earliest entry date in the data."),
plotlyOutput("progressdaysplot")
)
),
br(),
fluidRow(
column(12,
h4("Clients Who Have Not Been Issued a Voucher"),
plotlyOutput("progressdaystwoplot")
)
)
)#,
# Map tab ----
# tabItem(tabName = "map",
# fluidRow(
# column(12,
# h3("Map of Housing"),
# p("THIS IS AN EXAMPLE MAP! The following maps show where HACSL's vouchers are being used throughout Salt Lake County. The darker the blue, the more housing in that area."),
# HTML('<center><img src="slco map example.png"><center>'),
# br(),
# p("Here the map is zoomed out, but in the actual dashboard, you'll be able to do this in real time."),
# HTML('<center><img src="full Utah map.png"><center>'),
# br()
# )
# )
# )
)
)
)
# Define the server ------------------------------------------------------------------
server <- function(input, output) {
# Overview infographics ----
output$Individuals <- renderValueBox({
indiv <- demographics %>%
mutate(numindiv = TotalAdults + NumberKids)
indiv <- sum(indiv$numindiv, na.rm = TRUE)
valueBox(value = prettyNum(indiv, big.mark = ","), subtitle = "Individuals Served Since January 2018"
, color = "navy")
})
output$Families <- renderValueBox({
kids <- demographics %>%
filter(Kids==TRUE) %>%
count(Kids)
valueBox(value = prettyNum(kids$n, big.mark = ","), subtitle = "Households Served Since January 2018",
color = "blue")
})
output$Percent <- renderValueBox({
kidspercent <- demographics %>%
group_by(Kids) %>%
summarise(count = n()) %>%
mutate(percent = percent((count/sum(count)))) %>%
slice(2)
valueBox(value = prettyNum(kidspercent$percent, big.mark = ","), subtitle = "Percent of Households with Children Served Since January 2018",
color = "teal")
})
output$Vouchertime <- renderValueBox({
valueBox(value = prettyNum(0, big.mark = ","), subtitle = "Time to Housing: From Referral to Voucher Issued",
color = "yellow")
})
output$servedbymonth <- renderPlotly({
plot <- demographics %>%
mutate(CreatedDate = mdy(CreatedDate),
year = year(CreatedDate),
year_month = as.Date(cut(CreatedDate, breaks = "month"))) %>%
mutate(totalpeople = TotalAdults + NumberKids) %>%
filter(RelationshipHOH=="Head") %>%
filter(year>2010) %>%
group_by(year_month) %>%
summarise(n = sum(totalpeople))
plot_ly(plot, x= ~year_month, y= ~n, type = "scatter", mode = "lines", line = list(width = 3)) %>%
layout(
xaxis = list(title = "Year Month"),
yaxis = list(title = "# of People")
)
})
output$Vouchertime <- renderPlotly({
time1 <- dates %>%
filter(referraltopacketdays>=0) %>%
summarise(`Referral to Packet` = mean(referraltopacketdays)) %>%
round()
time2 <- dates %>%
filter(packettoappdays>=0) %>%
summarise(`Packet to Application` = mean(packettoappdays)) %>%
round()
time3 <- dates %>%
filter(appvouchdays>=0) %>%
summarise(`Application to Voucher` = mean(appvouchdays)) %>%
round()
time4 <- dates %>%
filter(vouchleasedays>=0) %>%
summarise(`Voucher to LeaseUp` = mean(vouchleasedays)) %>%
round()
time <- bind_cols(time1, time2)
time <- time %>% bind_cols(time3)
time <- time %>% bind_cols(time4) %>%
gather() %>%
rename(Time = key,
mean = value) %>%
mutate(Time = as.character(Time))
plot_ly(time, labels = ~Time, values = ~mean) %>%
add_pie(hole = 0.4) %>%
layout(showlegend = T,
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
# Demographics tab data and plots ----
# Reactive demographics data that changes with the sliders on that tab
selected.data <- reactive({
demographics %>%
{if(input$clienttype != 'All') filter(., client_type == input$clienttype) else .} %>%
{if(input$gender != 'All') filter(., Gender == input$gender) else .} %>%
{if(input$ethnicity != 'All') filter(., Ethnicity == input$ethnicity) else .} %>%
{if(input$race != 'All') filter(., Race == input$race) else .}
})
output$clientplot <- renderPlotly({
plot <- selected.data() %>%
count(client_type) %>%
plot_ly(labels = ~client_type, values = ~n, marker = list (colors = c("#3e4c89", "#28a683"))) %>%
add_pie(hole = 0.4) %>%
layout(showlegend = T,
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
output$client_timeplot <- renderPlotly({
allmonths <- demographics %>%
group_by(year_month) %>%
tally() %>%
select(-n)
ts <- selected.data() %>%
group_by(year_month) %>%
tally() %>%
right_join(allmonths) %>%
replace(is.na(.), 0)
plot <- ts %>%
plot_ly(x = ~year_month, y = ~n, group = 1,
type = "scatter", mode = "lines") %>%
layout(yaxis = list(title = 'Count'),
xaxis = list(title = 'Year and Month'))
})
output$client_genderplot <- renderPlotly({
plot <- selected.data() %>%
group_by(Gender) %>%
summarise(n = n()) %>%
plot_ly(labels = ~Gender, values = ~n, marker = list (colors = c("#2e738e", "#dce428"))) %>%
add_pie(hole = 0.4) %>%
layout(showlegend = T,
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
})
output$client_raceplot <- renderPlotly({
plot <- selected.data() %>%
group_by(Race) %>%
summarise(n = n()) %>%
plot_ly(x = ~Race, y = ~n, type = "bar", marker = list(color = "#3e4c89")) %>%
layout (
yaxis = list(title = 'Count'),
xaxis = list(title = 'Race'))
})
output$client_ethnplot <- renderPlotly({
plot <- selected.data() %>%
group_by(Ethnicity) %>%
summarise(n = n()) %>%
plot_ly(x = ~Ethnicity, y = ~n, type = "bar", marker = list(color = "#afdb39")) %>%
layout (
yaxis = list(title = 'Count'),
xaxis = list(title = 'Ethnicity'))
})
output$client_incomeplot <- renderPlotly({
plot <- selected.data() %>%
group_by(IncomeLevel) %>%
summarise(n = n()) %>%
plot_ly(x = ~IncomeLevel, y = ~n, type = "bar", marker = list(color = "#28a683")) %>%
layout (
yaxis = list(title = 'Count'),
xaxis = list(title = 'Income Level'))
})
output$client_kidplot <- renderPlotly({
plot <- selected.data() %>%
mutate(NumberKids = as.factor(NumberKids)) %>%
group_by(NumberKids) %>%
summarise(n = n()) %>%
plot_ly (x = ~NumberKids, y = ~n, type = "bar", marker = list(color = "#441665")) %>%
layout (
yaxis = list (title = 'Count'),
xaxis = list(title = 'Number of Children'))
})
# Housing tab data and plots ----
# Reactive demographics data that changes with the sliders on that tab
housing.data <- reactive({
demographics %>%
{if(input$clienttypeh != 'All') filter(., client_type == input$clienttypeh) else .} %>%
{if(input$genderh != 'All') filter(., Gender == input$genderh) else .} %>%
{if(input$ethnicityh != 'All') filter(., Ethnicity == input$ethnicityh) else .} %>%
{if(input$raceh != 'All') filter(., Race == input$raceh) else .}
})
output$rentplot <- renderPlotly({
plot <- housing.data() %>%
plot_ly (x = ~TotalRent, type = "histogram",
marker = list (color = c("#440255", "#440e5e", "#441665", "#442a75", "#433d82",
"#3e4c89", "#2e738e", "#26898d", "#28a683", "#35b679",
"#46bc72", "#72cc59", "#b3dc31", "#afdb39", "#cfe12c", "#dce428", "#fae725"))) %>%
layout(xaxis = list (title = "Total Rent $", tickformat = "$"),
yaxis = list (title = "Count"))
})
output$rentbytenantplot <- renderPlotly({
plot <- housing.data() %>%
plot_ly (x = ~TenantPaid, type = "histogram",
marker = list (color = c("#440255", "#440e5e", "#441665", "#442a75", "#433d82",
"#3e4c89", "#2e738e", "#26898d", "#28a683", "#35b679",
"#46bc72", "#72cc59", "#b3dc31", "#afdb39", "#cfe12c", "#dce428", "#fae725"))) %>%
layout(xaxis = list (title = "Amount Tenant Pays Toward Rent $",
tickformat = "$"),
yaxis = list (title = "Count"))
})
output$rentscatterplot <- renderPlotly({
plot <- housing.data() %>%
plot_ly (x = ~TotalRent, y = ~TenantPaid,
type = "scatter", mode = "marker",
color = ~TotalRent, size = ~TotalRent) %>%
layout (xaxis = list (title = "Total Rent $", tickformat = "$"),
yaxis = list (title = "Amount Tenant Pays Toward Rent $",
tickformat = "$"))
})
output$bedroomsplot <- renderPlotly({
plot <- housing.data() %>%
count(BedroomSize.y) %>%
plot_ly (x = ~BedroomSize.y, y = ~n,
type = "bar", marker = list(color = "#3e4c89")) %>%
layout (xaxis = list (title = "Number of Bedrooms"),
yaxis = list (title = "Number of Households"))
})
output$bedroomsrentplot <- renderPlotly({
plot <- housing.data() %>%
plot_ly(x = ~BedroomSize.y, y = ~TotalRent, type = "box", marker = list(color = 'rgb(7,40,89)'),
line = list(color = 'rgb(7,40,89)')) %>%
layout (xaxis = list (title = "Number of Bedrooms"),
yaxis = list (title = "Total Rent"))
})
output$typerentplot <- renderPlotly({
plot <- housing.data() %>%
plot_ly (x = ~Stuturetype, y = ~TotalRent, type = "box", marker = list(color = 'rgb(7,40,89)'),
line = list(color = 'rgb(7,40,89)')) %>%
layout (xaxis = list (title = "Type of Structure", tickfont = list (size = 7)),
yaxis = list (title = "Total Rent"))
})
# Duration plots ----
output$Vouchertimed <- renderValueBox({
tim <- dates %>%
filter(referraltopacketdays>=0) %>%
summarise(meandays = mean(referraltopacketdays)) %>%
round()
valueBox(value = prettyNum(tim, big.mark = ","), subtitle = "Average Number of Days from Referral to Packet Submitted", color = "navy")
})
output$Vouchertimedpacket <- renderValueBox({
tim <- dates %>%
filter(packettoappdays>=0) %>%
summarise(meandays = mean(packettoappdays)) %>%
round()
valueBox(value = prettyNum(tim, big.mark = ","), subtitle = "Average Number of Days from Packet to Application Processed", color = "blue")
})
output$Vouchertimedvoucher <- renderValueBox({
tim <- dates %>%
filter(appvouchdays>=0) %>%
summarise(meandays = mean(appvouchdays)) %>%
round()
valueBox(value = prettyNum(tim, big.mark = ","), subtitle = "Average Number of Days from Application to Voucher Issued", color = "teal")
})
output$Vouchertoleaseup <- renderValueBox({
tim <- dates %>%
filter(vouchleasedays>=0) %>%
summarise(meandays = mean(vouchleasedays)) %>%
round()
valueBox(value = prettyNum(tim, big.mark = ","), subtitle = "Average Number of Days from Voucher Issued to Lease Up", color = "navy")
})
output$Referraltovouch <- renderValueBox({
tim <- dates %>%
filter(referraltovoucher>=0) %>%
summarise(meandays = mean(referraltovoucher)) %>%
round()
valueBox(value = prettyNum(tim, big.mark = ","), subtitle = "Average Number of Days from Referral to Voucher Issued", color = "blue")
})
output$Referraltoleaseup <- renderValueBox({
tim <- dates %>%
filter(referraltoleaseup>=0) %>%
summarise(meandays = mean(referraltoleaseup)) %>%
round()
valueBox(value = prettyNum(tim, big.mark = ","), subtitle = "Average Number of Days from Referral to Lease Up", color = "teal")
})
output$timeplot <- renderPlotly({
plot <- datesgathered %>%
group_by(referral, name) %>%
filter(days>=0) %>%
filter(days<50) %>%
ungroup() %>%
bind_cols(g = as.factor(group_indices(., referral, name)))
plot_ly(plot, x= ~point, y= ~days, color = ~g, type = "scatter", mode = "lines", colors = "Spectral") %>%
layout(
xaxis = list(title = ""),
yaxis = list(title = "Days"),
legend = list(orientation = "h")
)
})
output$timetwoplot <- renderPlotly({
plot <- datesgathered %>%
group_by(referral, name) %>%
filter(days>=0) %>%
ungroup() %>%
bind_cols(g = as.factor(group_indices(., referral, name)))
plot_ly(plot, x= ~point, y = ~days, color = ~g, type = "scatter", mode = "lines", colors = "Spectral") %>%
layout(
xaxis = list(title = ""),
yaxis = list(title = "Days"),
legend = list(orientation = "h")
)
})
output$progressdaysplot <- renderPlotly({
plot <- dlong %>%
filter(!in_process) %>%
bind_cols(g = group_indices(., referral, name))
plot_ly(plot, x = ~g, y = ~days, type = 'bar',
name = ~pointname, color= ~pointname) %>%
layout(yaxis = list(title = "Days"),
xaxis = list(title = "Individuals Indexed by Date Entered"),
barmode = 'stack')
})
output$progressdaystwoplot <- renderPlotly({
plot <- dlong %>%
filter(in_process) %>%
bind_cols(g = group_indices(., referral, name)) %>%
mutate(g = as.factor(g))
plot_ly(plot, x= ~days, y = ~g, color = ~pointname, name = ~pointname, type = "bar", orientation = 'h') %>%
layout(
yaxis = list(title = "Individuals Indexed by Date Entered"),
xaxis = list(title = "Days Until Present"),
barmode = 'stack',
showlegend = T
)
})
}
# Run the app -------------------------------------------------------------
shinyApp(ui = ui, server = server)