Load the package.
library(CoV19)
The data are in the following objects. They have a few common columns: date, region, positive, death. Then there are some other columns depending on the source.
states italy world
Here is an example from states
:
head(states)
# Just WA x <- subset(states, region=="WA") # Two states x <- subset(states, region %in% c("WA","CA")) # All areas in China x <- subset(world, stringr::str_detect(region, "China"))
Let's say you want to have the sums for all regions. You can do that with dplyr
.
library(dplyr) # If you are unfamiliar with dplyr, the %>% is a pipe that sends # the result to the left into the function in the right x <- states %>% subset(region%in%c("WA","CA","OR")) %>% group_by(date) %>% summarize_if(is.numeric, sum, na.rm=TRUE) # This will not have the region column, so we add that back on x$region <- as.factor("WA + CA + OR")
We can pass this data object to plot2
to plot.
plot2(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.