library(tidyverse)
<- readxl::read_excel("data/FBO_dashboard_2015-2020.xlsx",
df skip = 2)
Overview
Map of European Countries Foodborne Campylobacter Outbreaks
, data is from www.efsa.europa.eu
Source:
Updates:
Foodborne outbreak:
<- df%>%
df1 select(1,contains("outbreak"))
names(df1) <- c("country",unlist(df1[1,2:23]))
<- df1%>%
df2 filter(!is.na(country))
%>%head df2
is.na(df2)]<-"0" df2[
<- df2%>%
df3 select(-country)%>%
mutate(across(where(is.character),as.numeric))%>%
cbind(country=df2$country)%>%
relocate(country)%>%
#select(-"0") %>%
pivot_longer(cols = 2:23,names_to="agent",values_to="values")%>%
mutate(agent=case_when(str_detect(agent,"other|Other|unknwon|Unknown")~"Other",
TRUE~agent)) %>%
filter(!agent=="Other")
library(tmap)
data("World")
<- World%>%
EU filter(continent=="Europe")
tm_shape(EU)+
tm_polygons()+
tm_text('name',size = .1,
col = "black",
bg.color = "white")
setdiff(df3$country,EU$name)
setdiff(EU$name,df3$country)
<- df3%>%
df4 mutate(country=case_when(str_detect(country,"Bos")~"Bosnia and Herz.",
=="Czechia"~"Czech Rep.",
country=="Republic of North Macedonia"~"Macedonia",
countryTRUE~country))%>%
filter(!country%in%c("Cyprus","Malta"))
setdiff(df4$country,EU$name)
setdiff(EU$name,df4$country)
library(rgdal)
library(raster)
<- df4%>%
df5 group_by(country)%>%
summarise(agents_mean=mean(values)) %>%
ungroup()
<- EU%>%
eu1 filter(!name%in%c("Albania","Belarus",
"Kosovo","Moldova",
"Russia","Slovenia",
"Ukraine"))%>%
left_join(df5,by=c("name"="country"))
library(sf)
%>%st_bbox()
eu1
<- World%>%
all left_join(df5,by=c("name"="country"))
tmap_mode("plot")
data(World, metro, rivers, land)
<- df3%>%
spread_df spread(agent,values)%>%
mutate(country=case_when(str_detect(country,"Bos")~"Bosnia and Herz.",
=="Czechia"~"Czech Rep.",
country=="Republic of North Macedonia"~"Macedonia",
countryTRUE~country))%>%
filter(!country%in%c("Cyprus","Malta"))
<- EU%>%
df_mapfilter(!name%in%c("Albania","Belarus",
"Kosovo","Moldova",
"Russia","Slovenia",
"Ukraine"))%>%
left_join(spread_df,by=c("name"="country"))
%>%st_bbox()
df_map<- c(xmin=-34.524754,
bbox ymin=20.053389,
xmax=31.516092,
ymax=80.657144)
<- tm_shape(df_map,bbox=bbox) +
map tm_polygons(col='Campylobacter',
title = "Agents") +
tm_text('iso_a3',
fontfamily = "Roboto Condensed",
root = 2,
size = .5,
col = "black",
bg.color = "white") +
tm_credits(
text="#30DayMapChallenge 2022 Day 15: Food/drink\nDataSource: www.efsa.europa.eu | Map: Federica Gazzelloni",
align = "center",
size=4,
fontface = "bold",
fontfamily = "Roboto Condensed",
position = "center")+
tm_scale_bar(text.size = 0.5,width = 0.4,
position = c(0.5,0.1))+
tm_style("natural",
inner.margins = .01)+
tm_layout(title="European countries\nFoodborne Campylobacter outbreaks",
main.title.fontfamily="Roboto Condensed",
legend.text.size=0.8,
legend.text.fontfamily="Roboto Condensed",
legend.just = 2,
legend.width = 0.4)
tmap_save(map,"day15_food_drink.png",width = 6.58,
height=7.24
# Saving 6.58 x 7.24 in image )