museums <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-11-22/museums.csv')
df <- museums %>%
filter(Year_closed < 2022) %>%
select(Name_of_museum, Longitude, Latitude, contains("Deprivation_index_")) %>%
pivot_longer(-c(Name_of_museum, Longitude, Latitude), names_to = "Variable", values_to = "Values") %>%
filter(Values <= 2)
museums_new <- museums %>% filter(Year_closed > 2022)
df$Variable<- factor(df$Variable, levels = c("Area_Deprivation_index_crime",
"Area_Deprivation_index_health", "Area_Deprivation_index_housing", "Area_Deprivation_index_services", "Area_Deprivation_index_income", "Area_Deprivation_index_education", "Area_Deprivation_index_employment"), labels = c("Crime", "Health", "Housing", "Services", "Income", "Education", "Employment"))
gg_point <- df %>%
ggplot()+
geom_point(data = museums_new, aes(x = Latitude, y = Longitude), size = 0.25, alpha = 0.70, color = "grey85")+
geom_point_interactive(aes(x = Latitude, y = Longitude, color = Variable, tooltip = Name_of_museum), size = 0.25, alpha = 1)+
facet_wrap(~Variable, ncol = 3)+
xlim(c(47,65))+
theme_cowplot(12)+
theme(axis.ticks = element_blank(), axis.text = element_blank(), axis.title = element_blank(), axis.line = element_blank(), legend.position = "none", plot.title = element_text(hjust = 0.5, size = 17), plot.subtitle = element_text(hjust = 0.5, face = "italic"), strip.background = element_rect(fill = "#898e9f"), strip.text = element_text(size = 10), plot.background = element_rect(fill = "seashell2"),
panel.background = element_rect(fill = "seashell2"))+
labs(title = 'How many UK Museums are in "Deprived" Regions?', subtitle = '"Deprived" Regions are defined as regions scoring a 2 or lower on the deprivation \nindex within each category below', caption = "Tidy Tuesday 11-22-2022 | Github: @scolando")+
scale_color_manual(values=met.brewer("Cross", 7))
## Warning: Removed 7 rows containing missing values (`geom_point()`).
saveWidget(x, "UKMuseum.html", selfcontained = T, libdir = "lib")