Exercise 2 - cleaning error messages

Receiving the following error message. Code is below.

Warning message:
Removed 685 rows containing non-finite outside the scale range (`stat_bin()`). 

Exercise 2 script

install and load packages

pacman::p_load(rio, here, janitor, tidyverse)

import data

surv_raw ← import(here(“data”, “raw”, “surveillance_linelist_20141201.csv”))

try to convert column to class “Date”

surv_clean ← surv_raw %>%
clean_names() %>%
mutate(onset_date = ymd(onset_date))

class(surv_clean$onset_date) # checking cleaned date column
range(surv_clean$onset_date) # checking cleaned date range

epicurve

ggplot(data = surv_clean,
mapping = aes(x = onset_date))+
geom_histogram()

Hey! This is a warning, not an error, and your plot was drawn. geom_histogram() has to place every row in a bin along the x axis, and rows where onset_date is NA have no position. ggplot drops them and tells you how many: 685 cases in your linelist have no usable onset date.

Best,

Luis