Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #20 from CityofEdmonton/fix-hoods-error
Browse files Browse the repository at this point in the history
fix error with left_join on colors
  • Loading branch information
reisner authored Jul 6, 2023
2 parents db68d9c + db4d98e commit 8768867
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions sentiment_neighbourhoods_module.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ mapPlot <- function(input, output, session,
aggregations = query_text_depot(query_info = query_info(),
aggregates_json = sentimentNeighbourhoodsQuery())
aggregations = parse_aggregates(es_results = aggregations)

bbox = sf::st_bbox(neighbourhoods)
min.lat = as.numeric(bbox$ymin)
max.lat = as.numeric(bbox$ymax)
Expand Down Expand Up @@ -114,17 +114,19 @@ mapPlot <- function(input, output, session,

pal = colorNumeric(palette = "Blues", domain = hoods_df$doc_count, reverse = FALSE)

colours = get_sentiment_colourmap()

hoods_df$label = ifelse(!is.na(hoods_df$avg_sentiment),
as.character(cut(hoods_df$avg_sentiment,
breaks = c(colour_map$lower, Inf),
labels = colour_map$label,
include.lowest = TRUE,
right = TRUE)),
breaks = c(colour_map$lower, Inf),
labels = colour_map$label,
include.lowest = TRUE,
right = TRUE)),
NA)
# Remove repeats of "NEUTRAL" so join doesnt cause issues:
colours = colour_map %>%
select(colour, legend_text_colour, label) %>%
distinct()
hoods_df = dplyr::left_join(hoods_df, colours, by = c("label" = "label"))

if (selected == "Sentiment") {
map = map %>%
addPolygons(
Expand Down Expand Up @@ -192,7 +194,7 @@ mapPlot <- function(input, output, session,
})

output$sentiment_colour_scale <- renderPlot({
colour_map <- get_sentiment_colourmap()
colour_map = get_sentiment_colourmap()
sentimentLegendPlot(colour_mapping = colour_map)
})
}
Expand Down

0 comments on commit 8768867

Please sign in to comment.