From 9865ca83d7d3cee50c8650aff70a93cefc5202fd Mon Sep 17 00:00:00 2001 From: Flavio Poletti Date: Thu, 25 Aug 2022 12:09:39 +0200 Subject: [PATCH] update district names in shiny app --- R/shinyapp.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/R/shinyapp.R b/R/shinyapp.R index 882c4df..66b3253 100644 --- a/R/shinyapp.R +++ b/R/shinyapp.R @@ -120,8 +120,13 @@ run_app = function(votes_matrix = NULL, district_seats = NULL) { run_biproporz = function() { if(sum(input$votes_matrix) == 0) return(NULL) if(sum(input$district_seats_matrix) == 0) return(NULL) + if(any(nchar(colnames(input$votes_matrix)) == 0)) return(NULL) district_seats = input$district_seats_matrix + if(ncol(district_seats) > 1 && isTRUE(input$set_seats_per_district)) { + colnames(district_seats) <- colnames(input$votes_matrix) + shinyMatrix::updateMatrixInput(session, "district_seats_matrix", district_seats) + } district_seats <- district_seats[1,] bp = biproporz(input$votes_matrix, district_seats,