Sort drop down menu and remove dependencies

This commit is contained in:
2025-12-08 19:44:19 +01:00
parent 218567f28e
commit 9c9866b9af

View File

@@ -5,8 +5,6 @@ library(leaflet)
library(sf)
library(htmltools)
library(dplyr)
library(tidyr)
library(purrr)
# Json of Crime Reports
crime_json <- fromJSON(file="data.json")
@@ -24,8 +22,8 @@ map_data_to_table <- function(bezirk, stadtteil, year) {
tibble(
Name = crime,
`Erfasste Fälle` = row[["Erfasste Fälle"]],
`Aufgeklärte Fälle` = row[["Aufgeklärte Fälle"]],
`Erfasste Fälle` = as.integer(row[["Erfasste Fälle"]]),
`Aufgeklärte Fälle` = as.integer(row[["Aufgeklärte Fälle"]]),
`Aufklärung relativ` = row[["Aufklärung relativ"]]
)
})
@@ -40,7 +38,7 @@ geo_bezirke$leaflet_id <- paste("bez_", geo_bezirke$bezirk, sep="")
geo_stadtteile <- st_read("geostadtteile-parsed.json")
geo_stadtteile <- st_transform(geo_stadtteile, crs = 4326)
geo_stadtteile$leaflet_id <- paste("std_", geo_stadtteile$stadtteil, sep="")
bezirke <- names(crime_json)
bezirke <- sort(names(crime_json))
#User interface definitions
@@ -54,8 +52,8 @@ ui <- function() {
textOutput("txt_map_selection_stadtteil"),
"2024",
tableOutput("tbl_2024"),
"2023",
tableOutput("tbl_2023"),
#"2023",
#tableOutput("tbl_2023"),
),
col_widths = c(7, 5),
),
@@ -110,14 +108,14 @@ update_selection_table <- function(output) {
),
striped = TRUE
)
output$tbl_2023 <- renderTable(
map_data_to_table(
bezirk = currently_selected_bezirk,
stadtteil = currently_selected_stadtteil,
year = "2023"
),
striped = TRUE
)
# output$tbl_2023 <- renderTable(
# map_data_to_table(
# bezirk = currently_selected_bezirk,
# stadtteil = currently_selected_stadtteil,
# year = "2023"
# ),
# striped = TRUE
# )
}
#Server handling user input and processing of data
@@ -128,6 +126,7 @@ server <- function(input, output, session){
if (sel_bezirk != "") {
sel_stadtteile <- names(crime_json[[sel_bezirk]])
selected_stadtteil <- paste("Bezirk", sel_bezirk)
updateSelectInput(
session,
inputId = "drp_stadtteil",