knitr::opts_chunk$set(echo = FALSE)
Showing most recent data available for each r group
.
r if(scale_vars) paste("Each map shows the *relative position* of each", group, "--- a score of 0 means average, and a score of 2 or -2 means far above or below average.")
vars <- pull(my_subset, variable) var_labs <- my_subset %>% pull(short_label) names(var_labs) <- vars scale2 <- function(x, na.rm = FALSE) { x <- as.numeric(x) (x - mean(x, na.rm = na.rm)) / sd(x, na.rm)} par(mar=c(0,0,0,0)) current_means_map <- current_means %>% data.frame() if(scale_vars) current_means_map <- current_means_map %>% mutate_at(my_subset$variable, scale2) df_map <- left_join(shp_df, current_means_map) %>% select(-date) %>% reshape2::melt(id.vars= c("id", "long", "lat", "order", "hole", "piece", "group")) ggplot() + geom_polygon(data = df_map, aes( x = long, y = lat, group = group, fill=value), color="white") + theme_void() + coord_map() + facet_wrap(~variable, labeller = labeller(variable = var_labs))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.