[R-sig-Geo] counties plot in R

Milan Sharma milansharma2012 at yahoo.com
Mon Feb 18 22:55:11 CET 2013


Hi list/ Roger,
I tried just 3 states as you said, I merged state and county names to make sure the county names are different.
Here is the error message.

library(maptools)
library(maps)
library(spdep)
library(rgdal)
library(alr3)
 data<-read.csv("try3.csv",header=TRUE)
> attach(data)
> names(data)
[1] "State"     "NAME"      "county"    "Longitude" "Latitude"  "yield"    
[7] "temp"      "precpt"   
> sd<-map("county", c("Illinois","Indiana","Iowa"), fill=F, plot=F)
> county.names<-as.character(sd$names)
> sd.sp<-map2SpatialPolygons(sd, IDs=county.names, proj4string=CRS("+proj=longlat"))
Error in map2SpatialPolygons(sd, IDs = county.names, proj4string = CRS("+proj=longlat")) : 
  map and IDs differ in length
> 
How do I solve the problem of matching?
Milan




More information about the R-sig-Geo mailing list