Search code examples
rdictionarygeomap

Vector length mismatch in Swiss Language Map


I am studying this website

and don't understand some things:

con <- url("http://biogeo.ucdavis.edu/data/gadm2/R/CHE_adm1.RData")
print(load(con))

Output is

[1] "gadm"

The code continues by closing the connection

close(con)

Then I execute

language <- c("german", "german", "german","german",
 "german","german","french", "french",
 "german","german","french", "french", 
 "german", "french","german","german",
 "german","german","german", "german",
 "german","italian","german","french",
 "french","german","german")

Honestly, I don't know how the person came up with this matrix, but then I get error

Error in `[[<-.data.frame`(`*tmp*`, name, value = c(2L, 2L, 2L, 2L, 2L,  : 
  replacement has 27 rows, data has 26

Please guide


Solution

  • It seems that one "french" entry should be removed from the list at the end of the third line. I don't know if this was a mistake in the example or a change in the data of the map (formerly at http://gadm.org/data/rda/CHE_adm1.RData , now at http://biogeo.ucdavis.edu/data/gadm2/R/CHE_adm1.RData). In any case I could reproduce the map shown on the website by using:

    language <- c("german", "german", "german","german",
              "german","german","french", "french",
              "german","german","french",  
              "german", "french","german","german",
              "german","german","german", "german",
              "german","italian","german","french",
              "french","german","german")
    

    enter image description here