library(readr)
d = WHO_COVID_19_global_data_1_ <- read_csv("WHO-COVID-19-global-data (1).csv", 
    col_types = cols(Date_reported = col_date(format = "%Y-%m-%d")))
d_sw = d %>% filter(Country == "Sweden") %>% as.data.frame()
log <- d_sw

log$Date_reported <- as.Date(log$Date_reported,
  "%Y-%m-%d")

log$Month <- as.Date(cut(log$Date_reported,
  breaks = "month"))
log$Week <- as.Date(cut(log$Date_reported,
  breaks = "week"))
log$Day <- as.Date(cut(log$Date_reported,
  breaks = "day"))

ggplot(data = log, aes(Month, Cumulative_deaths)) +
stat_summary(fun = sum, geom = "bar", color='darkblue', fill = "blue") + scale_x_date(
    breaks = "1 month") 

ggplot(data = log, aes(Day, Cumulative_deaths)) +
stat_summary(fun= sum, geom = "bar", color="red", fill="darkblue", ) + scale_x_date(
    breaks = "30 days") 

q = ggplot(data = log, aes(Date_reported, New_deaths)) + labs(y = "Count of new characters", x = "")  + geom_path() +  facet_wrap(. ~ Month)
q
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

d_usa = d %>% filter(Country == "United States of America") %>% as.data.frame()
log2 <- d_usa

log2$Date_reported <- as.Date(log2$Date_reported, "%Y-%m-%d")

log2$Month <- as.Date(cut(log2$Date_reported,
  breaks = "month"))
log2$Week <- as.Date(cut(log2$Date_reported,
  breaks = "week"))
log2$Day <- as.Date(cut(log2$Date_reported,
  breaks = "day"))

ggplot(data = log2, aes(Month, Cumulative_deaths)) +
stat_summary(fun = sum, geom = "bar", color='darkblue', fill = "blue") + scale_x_date(
    breaks = "1 month") 

ggplot(data = log2, aes(Day, Cumulative_deaths)) +
stat_summary(fun= sum, geom = "bar", color="red", fill="darkblue", ) + scale_x_date(
    breaks = "30 days") 

q = ggplot(data = log2, aes(Date_reported, New_deaths)) + geom_line() +  facet_wrap(. ~ Month)
q

d_ger = d %>% filter(Country == "Germany") %>% as.data.frame()
log3 <- d_ger

log3$Date_reported <- as.Date(log3$Date_reported, "%Y-%m-%d")

log3$Month <- as.Date(cut(log3$Date_reported,
  breaks = "month"))
log3$Week <- as.Date(cut(log3$Date_reported,
  breaks = "week"))
log3$Day <- as.Date(cut(log3$Date_reported,
  breaks = "day"))

ggplot(data = log3, aes(Month, Cumulative_deaths)) +
stat_summary(fun = sum, geom = "bar", color='darkblue', fill = "blue") + scale_x_date(
    breaks = "1 month") 

ggplot(data = log3, aes(Day, Cumulative_deaths)) +
stat_summary(fun= sum, geom = "bar", color="red", fill="darkblue", ) + scale_x_date(
    breaks = "30 days") 

q = ggplot(data = log3, aes(Date_reported, New_deaths)) + geom_line() +  facet_wrap(. ~ Month)
q

```