Description Usage Arguments Value Source Examples
View source: R/coronavirus_spatial.R
Create a geospatial version of the coronavirus data set for easier visualization and spatial analysis. Uses rnaturalearth for the the spatial info and generates sf objects using st_join to match up datasets.
1 2 3 4 5 | coronavirus_spatial(
return_shape = c("point", "polygon"),
returncols = c("all", "simple", "reduced"),
...
)
|
return_shape |
Should the sf object returned be points for cases or polygons of countries? Defaults to 'point'. |
returncols |
What coluns do you want returned. Defaults to 'all', giving all columns from the original 'coronavirus' dataset as well as those returned by ne_countries. 'simple' returned those from 'coronavirus' as well as some larger scale geographic information. 'reduced' returns the info from 'simple' as well as information on population, income, and a number of ISO codes. |
... |
Other arguments to ne_countries |
An 'sf' object with either country borders as polygons or cases as points
Johns Hopkins University Center for Systems Science and Engineering (JHU CCSE) Coronavirus website
The rnaturalearth
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Not run:
library(ggplot2)
library(dplyr)
library(rnaturalearth)
worldmap <- ne_countries(returnclass = "sf")
coronavirus_points <- coronavirus_spatial() %>%
filter(date == "2020-03-08") %>%
filter(type == "confirmed")
coronavirus_polys <- coronavirus_spatial(return_shape = "polygon")%>%
filter(date == "2020-03-08")%>%
filter(type == "confirmed")
ggplot(worldmap) +
geom_sf() +
geom_sf(data = coronavirus_polys, aes(fill = log10(cases+1))) +
geom_sf(data = coronavirus_points) +
scale_fill_viridis_c() +
theme_void()
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.