Help creating a map

New to R. having a problem getting R to create map from a Map.from a colleague in Germany. need some help. his instructions: Help!

###### load objects
load("weimar.RData")                                                            # object: weimar
load("weimar_map.RData")                                                 # object: weimar_map


##### load library
library(grImport)                                                               # used version: version 0.9-0 with R version 3.1.2 (2014-10-31), Platform: x86_64-w64-mingw32/x64 (64-bit)


################################################################################
################################################################################
################################################################################
###### define basis plot function

## objects
# map:      map as grObject (weimar_map[[2]][[1]])
# indexv:   reference, region number of corresponding grObject polygon, e.g. first polygon is region 10, therefore, the first entry should be 10 (weimar_map[[2]][[2]])
# plotv:    region code of regions to plot, e.g. if only region 10 shall be plotted => plotv = 10, using NA plot all region with a region code below 5000
# borderb:  outer borders, logical [plots polygons with region code 8000]
# pborderb: province borders, logical [plots polygons with region code 8500]
# iborderb: inner borders, logical  [plots polygons with region code 9000]
# col:      colorvector, must have the same order as plotv, NA: 'random' colors
# bcol:     color of the region polygons border
# blw:      linewidth, standard = 1

plot.map = function(map, indexv, plotv = NA, borderb = FALSE, iborderb = FALSE, pborderb = FALSE ,col = NA, bcol = NA, blw = 1){
    if (is.na(plotv[1])){
      plotv = 1:5000
    }
    plotvec = !is.na(match(indexv, plotv))          # Regionen die von plotv in indexv vorkommen, werden gezeichnet
    if (is.na(col[1])){
      t.col = hcl(sample(seq(0, 360, length.out=length(plotv))), 60, 60)
    } else {
      t.col = col
    }
    colours = rep(NA,length(plotvec))
    for (i in 1:length(plotv)){
      colours[which(!is.na(match(indexv,plotv[i])))] = t.col[i]
    }
    if (is.na(bcol[1]) | (bcol[1] == -1) ){
      bcol = colours
    }
        pic.bord = plotvec
    if (borderb){
      pic.bord[which(!is.na(match(indexv, 8000)))] = TRUE
    }
    if (iborderb){
      pic.bord[which(!is.na(match(indexv, 9000)))] = TRUE
    }
    grid.newpage()
    pushViewport(grImport:::pictureVP(map[pic.bord]))
    for (i in 1:length(plotvec)){
      if (plotvec[i]){
        grid.polygon(map[i]@paths$path@x, map[i]@paths$path@y, default.units="native",  gp=gpar(col= bcol, lwd = blw, fill=colours[i]))
      }
    }
    if (iborderb){
      bordvec = !is.na(match(indexv, 9000))
      for (i in 1:length(bordvec)){
        if (bordvec[i]){
          grid.lines(map[i]@paths$path@x, map[i]@paths$path@y, default.units="native",  gp=gpar(col= "black", lwd = 1.5))
        }
      }
    }
    if (pborderb){
      bordvec3 = !is.na(match(indexv, 8500))
      for (i in 1:length(bordvec3)){
        if (bordvec3[i]){
          grid.lines(map[i]@paths$path@x, map[i]@paths$path@y, default.units="native",  gp=gpar(col= "black", lwd = 1.5, lty = "dotdash"))
        }
      }
    }
    if (borderb){
    bordvec2 = !is.na(match(indexv, 8000))
      for (i in 1:length(bordvec2)){
        if (bordvec2[i]){
          grid.lines(map[i]@paths$path@x, map[i]@paths$path@y, default.units="native",  gp=gpar(col= "black", lwd = 2))
        }
      }
    }
}

# the map itself includes some additional placeholder polygons:
## 10000 legend position placeholder
## 10003 main title placeholder
## 10004 sub title placeholder (under the map)