From 9c9866b9af1c5d749f9061b485a1fc9ee8f1b9ba Mon Sep 17 00:00:00 2001 From: Millicool Date: Mon, 8 Dec 2025 19:44:19 +0100 Subject: [PATCH] Sort drop down menu and remove dependencies --- IT Shiny App.R | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/IT Shiny App.R b/IT Shiny App.R index d52bfbb..b45df5c 100644 --- a/IT Shiny App.R +++ b/IT Shiny App.R @@ -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",