I'm trying to replicate a relatively simple visualization from the NYT on COVID deaths. I'm using a jitter plot, with each point representing a death on a given day. It's almost perfect, except that R doesn't seem to want to squish the points that go past my date limit.
The NYT U.S. COVID data contains cumulative cases and deaths per day from Jan 21 2020 to Jan 26 2021, and can be found here: https://github.com/nytimes/covid-19-data
library(tidyverse) library(scales) us <- read_csv("NYT Data/us.csv") #uncounting data so that each new death is one observation us_covid_deaths <- us %>% mutate(new_deaths = c(0, diff(deaths))) %>% filter(new_deaths > 0) %>% mutate(type = "death") %>% select(-c("cases", "deaths")) %>% uncount(new_deaths) horizontal_plot <- ggplot(us_covid_deaths, aes(x = date, y = type, stroke = 0)) + geom_jitter(shape = ".", width = 3) + scale_x_date(limits = as.Date(c("2020-02-20", "2021-01-26"))) + theme(axis.title = element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), legend.position = "none", panel.grid = element_blank()) horizontal_plot I get the following error message and R excludes from the plot about 3000 data points that have been "jittered" beyond my x limit.
"Error in scale_x_date(limits = as.Date(c("2020-02-20", "2021-01-26")), : unused argument (oob = squish)"
How can I get R to squish in all of my data?
https://stackoverflow.com/questions/65945102/unused-argument-oob-squish January 29, 2021 at 04:54AM
没有评论:
发表评论