Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's a solution using rworldmap.</p> <p>library(rworldmap)</p> <pre><code>#Your data formdate &lt;- read.table(text=" ISO3\tCountry\tFormation Date DZA\tAlgeria\t07-03-1962 AGO\tAngola\t11-11-1975 BWA\tBotswana\t09-30-1966 CMR\tCameroon\t01-01-1960 BGD\tBangladesh\t03-26-1971 IND\tIndia\t08-15-1947 ISR\tIsrael\t05-14-1948 LOS\tLaos\t10-22-1953 MYS\tMalaysia\t09-16-1963 SGP\tSingapore\t08-09-1965" ,sep="\t",header=TRUE) #just using year as a first step formdate$Formation.Year&lt;-year(formdate$Formation.Date) #sPDF &lt;- joinCountryData2Map( formdate, joinCode="ISO3", nameJoinColumn="ISO3") #joining by country name works better because of incorrect ISO3 code for Laos in the data sPDF &lt;- joinCountryData2Map( formdate, joinCode="NAME", nameJoinColumn="Country") #Using defaults, change catMethod, numCats &amp; colourPalette to change map appearance mapCountryData(sPDF, nameColumnToPlot="Formation.Year") </code></pre> <p>... and for the 2nd bit to produce 3 panels with maps for different years :</p> <pre><code>#I've used these breaks that work with your sample data, #simply cahnge to work with full dataset yearBreak1 &lt;- 1960 yearBreak2 &lt;- 1970 oldPar &lt;- par(mar=c(0.7, 0, 0, 0)) #set margins for subplots top,bottom,left,right #use layout to set up 3 panels nPanels &lt;- layout( cbind(c(0,1:3)) , heights=c(lcm(0.5),c(1,1,1)) , respect=F ) #add a constant column to allow plotting all countries the same colour formdate$constant &lt;- 1 #subet data by yearBreaks dF1 &lt;- formdate[ formdate$Formation.Year &lt;= yearBreak1, ] dF2 &lt;- formdate[ formdate$Formation.Year &gt; yearBreak1 &amp; formdate$Formation.Year &lt;= yearBreak2, ] dF3 &lt;- formdate[ formdate$Formation.Year &gt; yearBreak2, ] #join to a map sPDF1 &lt;- joinCountryData2Map( dF1, joinCode="NAME", nameJoinColumn="Country") sPDF2 &lt;- joinCountryData2Map( dF2, joinCode="NAME", nameJoinColumn="Country") sPDF3 &lt;- joinCountryData2Map( dF3, joinCode="NAME", nameJoinColumn="Country") #plot &amp; add titles mapCountryData(sPDF1, nameColumnToPlot="constant", catMethod='categorical', addLegend=FALSE, mapTitle="" ) mtext(paste("&lt;=",yearBreak1)) mapCountryData(sPDF2, nameColumnToPlot="constant", catMethod='categorical', addLegend=FALSE, mapTitle="" ) mtext(paste("&gt;",yearBreak1,"&amp; &lt;=",yearBreak1)) mapCountryData(sPDF3, nameColumnToPlot="constant", catMethod='categorical', addLegend=FALSE, mapTitle="" ) mtext(paste("&gt;",yearBreak2)) </code></pre> <p>Should produce this : <img src="https://i.stack.imgur.com/L8UAa.png" alt="rworldmap plot"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload