In R, I have df1, df2, and df3 that represent lightning storms. Each df has two columns, 'city' and 'injuries'.
df1 = data.frame(city=c("atlanta", "new york"), injuries=c(5,8))
df2 = data.frame(city=c("chicago", "new york"), injuries=c(2,3))
df3 = data.frame(city=c("los angeles", "atlanta"), injuries=c(1,7))
I want to merge all 3 data frames on a type of outer join on the city column so that all the cities will show up in the combined dataframe and the injury counts will be summed like this:
combined.df
city df1.freq df2.freq df3.freq
atlanta 5 0 7
new york 8 3 0
chicago 0 2 0
los angeles 0 0 1