Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Probably not the most straight-forward way of doing it but here is a solution to your first point:</p> <pre><code># First changing the class of the two columns we're going to use: formdate$Formation.Date&lt;-as.Date(formdate$Formation.Date, "%m-%d-%Y") formdate$ISO3&lt;-as.character(formdate$ISO3) formdate$ISO3[8]&lt;-"LAO" #Laos'ISO3 code is "LAO" and not "LOS" in the wrld_simpl data # Make regular temporal interval intval &lt;- cut(formdate$Formation.Date, breaks = seq(min(formdate$Formation.Date),max(formdate$Formation.Date),length=5), right=TRUE, include.lowest=TRUE) # So that the intervals include the lowest date and the highest # Make these values correspond with their polygons library(maptools) data(wrld_simpl) f &lt;- rep(NA,nrow(wrld_simpl@data)) f[sapply(formdate$ISO3,function(x)which(wrld_simpl$ISO3==x))] &lt;- intval # Plot plot(wrld_simpl, col=(1:6)[f]) </code></pre> <p>For your second point:</p> <pre><code>#This time you can define your breakpoints before hand (don't forget to include a minimum age and a maximum age) d &lt;- c("1900/01/01","1945/01/01","1965/01/01","2020/01/01") intval &lt;- cut(formdate$Formation.Date, breaks = as.Date(d)) f &lt;- rep(0,nrow(wrld_simpl@data)) f[sapply(formdate$ISO3,function(x)which(wrld_simpl$ISO3==x))] &lt;- intval </code></pre> <p>and then the plotting:</p> <pre><code>par(mfcol=c(3,1)) #Here, three vertical panels for(i in 1:3){ par(mar=c(0,0,0,0)) plot(wrld_simpl) #First plot the whole world if(any(f==i)){ plot(wrld_simpl[f==i,],add=TRUE,col="red") #Then the countries that belong to the proper category } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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