-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
85 lines (68 loc) · 3.45 KB
/
server.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
library(shiny)
library(DT)
library(ggplot2)
source("charts_tables.R")
shinyServer(function(input, output, session) {
# Define table mappings based on the categories in selectInput
category_tables <- list(
"Overall Rank" = table1_2_overall_score_rank,
"Highway Performance Ranking by Category" = table3_all_categories,
"Overall Highway Performance Ranking Trends" = table4_ranking_trend,
"State-controlled Highway Miles" = table5_state_controlled_miles,
"State-controlled Highway Mileage by System Width"= table6_state_controlled_mileage_width,
"Capital and Bridge Disbursements"= table7_capital_disbursement,
"Maintenance Disbursements"= table8_maintenance_disbursement,
"Administrative Disbursements"= table9_admin_disbursement,
"Other Disbursements" = table10_other_disbursement,
"Percent Rural Interstate Mileage in Poor Condition" = table11,
"Percent Urban Interstate Mileage In Poor Condition" = table12,
"Percent Rural Other Principal Arterial Mileage In Poor Condition" = table13,
"Percent Urban Other Principal Arterial Mileage In Poor Condition" = table14,
"Annual Peak Hours Spent In Congestion Per Auto Commuter" = table15,
"Percent Structurally Deficient Bridges" = table16,
"Fatality Rate Per 100 Million Rural Vehicle-Miles" = table17,
"Fatality Rate Per 100 Million Urban Vehicle-Miles" = table18,
"Fatality Rate Per 100 Million Other Vehicle-Miles" = table19
)
# Define map category mappings to the corresponding metric for maps
category_maps <- list(
"Overall Rank" = "Overall Score",
"Highway Performance Ranking by Category" = "Capital Disbursement Score",
"Capital and Bridge Disbursements"= "Capital Disbursement Score",
"Maintenance Disbursements"= "Maintenance Disbursement Score",
"Administrative Disbursements"= "Admin Disbursement Score",
"Other Disbursements" = "Other Disbursement Score",
"Percent Rural Interstate Mileage in Poor Condition" = "Rural Interstate Score",
"Percent Urban Interstate Mileage In Poor Condition" = "Urban Interstate Score",
"Percent Rural Other Principal Arterial Mileage In Poor Condition" = "Rural Opa Score",
"Percent Urban Other Principal Arterial Mileage In Poor Condition" = "Urban Opa Score",
"Annual Peak Hours Spent In Congestion Per Auto Commuter" = "Congestion Hours Score",
"Percent Structurally Deficient Bridges" = "Bridges Score",
"Fatality Rate Per 100 Million Rural Vehicle-Miles" = "Rural Fatalities Score",
"Fatality Rate Per 100 Million Urban Vehicle-Miles" = "Urban Fatalities Score",
"Fatality Rate Per 100 Million Other Vehicle-Miles" = "Other Fatalities Score"
)
# Render the table based on the selected category
output$ranking_table <- renderDT({
selected_category <- input$category
table_to_show <- category_tables[[selected_category]]
table_to_show
})
output$ranking_map <- renderPlotly({
selected_category <- input$category
if(selected_category == "Overall Highway Performance Ranking Trends"){
plot_overall_changes
}else if (selected_category == "State-controlled Highway Miles"){
plotly_fig5_state_control
}
else if (selected_category == "State-controlled Highway Mileage by System Width"){
plotly_fig6_SHA_ratio
}
else{
metric <- category_maps[[selected_category]]
if (!is.null(metric)) {
create_maps(df_for_map, metric)
}
}
})
})