How to add population (based on the sizes of circles) to the map in R?

I have two data sets named covid and sp. The results of dput(head(covid)) and dput(head(sp)) are as follow:

> dput(head(covid))
structure(list(Province = c("EC", "FS", "GT", "KZ", "LM", "MP"
), Cases = c(2748L, 208L, 2993L, 1882L, 132L, 103L), Population = c(11.56, 
2.75, 12.27, 10.27, 5.4, 4.04)), row.names = c(NA, 6L), class = "data.frame")

> dput(head(sp))
structure(list(ID_0 = c("211", "211", "211", "211", "211", "211"
), ISO = c("ZAF", "ZAF", "ZAF", "ZAF", "ZAF", "ZAF"), NAME_0 = c("South Africa", 
"South Africa", "South Africa", "South Africa", "South Africa", 
"South Africa"), ID_1 = c("1", "2", "3", "4", "5", "6"), NAME_1 = c("Eastern Cape", 
"Free State", "Gauteng", "KwaZulu-Natal", "Limpopo", "Mpumalanga"
), TYPE_1 = c("Provinsie", "Provinsie", "Provinsie", "Provinsie", 
"Provinsie", "Provinsie"), ENGTYPE_1 = c("Province", "Province", 
"Province", "Province", "Province", "Province"), NL_NAME_1 = c(NA_character_, 
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_
), VARNAME_1 = c("Oos-Kaap", "Orange Free State|Vrystaat", "Pretoria/Witwatersrand/Vaal", 
"Natal and Zululand", "Noordelike Provinsie|Northern Transvaal|Northern Province", 
"Eastern Transvaal")), row.names = 0:5, class = "data.frame")

The classes of covid and sp are as follow:

> class(sp)
[1] "SpatialPolygonsDataFrame"

[1] "sp"
> class(covid19)
[1] "data.frame"

I added the Province column of covid to sp, and then I merged them, using below commands:

> sp@data$Province<-covid$Province
> sp@data<,covid,by="Province")

Then using plot(sp) I drow the below map:

enter image description here

But I need to have a map exactly like below map which include circles witht different sizes as population. Could you please help me how I can code to have a map like the below map? (Indeed, I want to change the shape of thte above map to the below map)

enter image description here

Read more here:

Content Attribution

This content was originally published by Rojer at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: