2021-05-26 17:15:22 +02:00
|
|
|
library(dplyr)
|
|
|
|
library(highcharter)
|
|
|
|
library(xts)
|
|
|
|
#install.packages("rworldmap")
|
|
|
|
library(rworldmap)
|
|
|
|
#install.packages("countrycode")
|
|
|
|
#library(countrycode)
|
|
|
|
#install.packages("rgeos")
|
|
|
|
library(rgeos)
|
|
|
|
library(ggplot2)
|
|
|
|
#install.packages("rgdal")
|
|
|
|
library(rgdal)
|
|
|
|
#install.packages("devtools")
|
|
|
|
#library(devtools)
|
|
|
|
library(dplyr)
|
|
|
|
library(viridis)
|
|
|
|
##install_github("dgrtwo/gganimate", ref = "26ec501")
|
|
|
|
#install.packages("hms")
|
|
|
|
library(hms)
|
|
|
|
#install.packages("gganimate")
|
|
|
|
library(gganimate)
|
|
|
|
|
|
|
|
library(zoo)
|
|
|
|
|
|
|
|
cov <- read.csv("proj2/max-covid.csv", header = TRUE)
|
|
|
|
|
|
|
|
#df <- data.frame(as.Date(cov$date, format="%Y-%m-%d"), cov$iso_code, cov$total_cases)
|
|
|
|
df <- data.frame(as.Date(cov$date), cov$iso_code, cov$total_cases)
|
2021-05-26 17:22:26 +02:00
|
|
|
#colnames(df) <- c('date', 'iso', 'total_cases')
|
2021-05-26 17:15:22 +02:00
|
|
|
|
|
|
|
#df$date = format(df$date, "%Y-%m")
|
|
|
|
|
|
|
|
#dd <- df %>% group_by(iso, date)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#df %>% mutate(date2 = format(cov.date, "%Y-%m")) %>% group_by(cov.iso_code, date2) %>% summarise(total = sum(cov.total_cases))
|
|
|
|
|
|
|
|
|
|
|
|
#df = df[order(as.Date(df$cov.date, format="%Y-%m-%d")),]
|
|
|
|
|
|
|
|
casesmax = max(df$total_cases, na.rm=T)
|
|
|
|
casesmin = min(df$total_cases, na.rm=T)
|
|
|
|
|
|
|
|
wmap <- getMap(resolution="low")
|
|
|
|
|
|
|
|
#wmap <- spTransform(wmap, CRS("+proj=robin")) # reproject
|
|
|
|
wmap_df <- fortify(wmap, region = "ISO3")
|
|
|
|
wmap_df <- left_join(wmap_df, df, by = c('id'='cov.iso_code'))
|
|
|
|
|
|
|
|
ggplot(data=wmap_df, frame = date) +
|
|
|
|
geom_polygon(aes(x = long, y = lat, group = group, fill=cov.total_cases), color="gray90") +
|
2021-05-26 17:22:26 +02:00
|
|
|
scale_fill_viridis(name="Zachorowania", na.value="white") +
|
2021-05-26 17:15:22 +02:00
|
|
|
theme_void() +
|
|
|
|
guides(fill = guide_colorbar(title.position = "top")) +
|
2021-05-26 17:22:26 +02:00
|
|
|
labs(title = "Liczba zachorowań w dniu 31.05.2021")
|
|
|
|
#+
|
|
|
|
# theme( legend.position = c(.5, .08),
|
|
|
|
# legend.direction = "horizontal",
|
|
|
|
# legend.title.align = 0,
|
|
|
|
# legend.key.size = unit(1.3, "cm"),
|
|
|
|
# legend.title=element_text(size=17),
|
|
|
|
# legend.text=element_text(size=13) )
|
2021-05-26 17:15:22 +02:00
|
|
|
#+
|
|
|
|
# transition_time(date)
|
|
|
|
|
|
|
|
#gganimate(o)
|
|
|
|
|
|
|
|
#gg_animate(o, "output4020_old.gif", title_frame =T,
|
|
|
|
# ani.width=1600, ani.height=820, dpi=800, interval = .4)
|