I want to make a graphic with the total positive cases of each city per year.
For example in Butte in 2006 there has been a total of (invented) 34 cases so I need this but with every city.
I want to make a graphic with the total positive cases of each city per year.
For example in Butte in 2006 there has been a total of (invented) 34 cases so I need this but with every city.
For example,
aggregate(Positive.Cases ~ Year + County, data=df, sum)
You have the documentation here : aggregate_function
Hope I was able to help you.
 
    
    > aggregate(Positive.Cases ~ Year + County, FUN=sum, data=data)
  Year       County Positive.Cases
1 2006      Alameda             13
2 2006        Butte             93
3 2006 Contra Costa             40
4 2006       Coulsa             22
# Barplot
library(ggplot)
library(dplyr)
data %>%
  mutate(Year = factor(Year)) %>%
  group_by(Year, County) %>%
  summarise(Case=sum(Positive.Cases)) %>%
  ggplot(aes(Year, Case,fill=County)) +
  geom_bar(stat="identity", position="dodge")
