#
# ebola outbreaks
#畫地圖使用的package
library(rworldmap)
dta <- read.table("C:/tmp/ebola.txt", h = T)
library(countrycode)
# a data.frame with the ISO3 country names plus a variable to
# merge to the map data
#rep( [ 指定的向量], [使之重複的次數])
dta$Country <- countrycode(dta[,1], "country.name", "iso3c")
dta$Ebola <- rep(1, length(dta$Country))
#繪制具有國家/地區的地圖顏色
mapDevice("x11")
# join the data.frame to the country map data
ebolaMap <- joinCountryData2Map(dta, joinCode = "ISO3", nameJoinColumn = "Country")## 8 codes from your data successfully matched countries in the map
## 0 codes from your data failed to match with a country code in the map
## 235 codes from the map weren't represented in your data
# plot it, the color palette's first color is red
mapCountryData(ebolaMap, nameColumnToPlot = "Ebola", catMethod = "categorical",
addLegend = FALSE, mapTitle =" ", missingCountryCol = gray(.9))## png
## 2