Displaying 1 result from an estimated 1 matches for "mapnamesnew".
2012 Jun 28
2
R help, using R to build choropleth
...le of the country, and also the population data,
however, i am having trouble to create the plot, below is my code:
population=read.csv("nz2.csv")
population
names(population)
nz=readShapeSpatial((sprintf('nz-geodetic-marks',tmp_dir)))
nz$land_distr
mapnames = nz$land_distr
mapnamesnew=as.character(mapnames)
popnames =as.character(mapnamesnew)
pop =population$People
pop2=as.numeric(pop)
popdich = ifelse(pop2 < 100000, "red", "blue")
popnames.lower = tolower(popnames)
cols=popdich[match(mapnames,popnames.lower)]
plot(nz,fill=TRUE,col=cols,proj="GCS...