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) library(scales) 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) #colnames(df) <- c('date', 'iso', 'total_cases') #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") + scale_fill_viridis(name="Zachorowania", na.value="white", labels = comma) + theme_void() + guides(fill = guide_colorbar(title.position = "top")) + 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) ) #+ # transition_time(date) #gganimate(o) #gg_animate(o, "output4020_old.gif", title_frame =T, # ani.width=1600, ani.height=820, dpi=800, interval = .4)