I am trying to calculate the cumulative confirmed cases rate (i.e. cases per 10000 population) and the cumulative death rate by month from two DF and plot it into a map.
Here's the DF that I have
- DF1 - clean_dif - [Province, City, District, Sub_District, Cases, Death, Month, ID]
- DF2 - indo_filter_3 - [Object_ID, Village_Code, Village, ID, Province, City, District, Sub_District, Total_Populatiom, Gemoetry]
Here's what I have tried so far and I guess the reason why it doesn't work is cause Total_Population
is not inside clean_df
but inside indo_filter_3. How do I create a new calculation field from two different DF (Indo_filter_3
& clean_df
) and then create a chloropleth map?
new_df <- clean_df %>%
group_by(Sub_District, Month) %>%
summarise(`Cases` = sum(as.numeric(Cases))/Total_Population)
tmap_mode("plot")
tm_shape(new_df)+
tm_fill("Cases_Pop",minimize = TRUE) +
tm_borders(alpha = 0.5)