Hello,

I' m still beginner (two days of practice), and I failed in the example
script from the ASFAR Book, about SpatialPolygonsDataFrame (example page
45).

 

Can you help me?

 

Sincerely

 

state.map<-map("state",plot=FALSE,fill=TRUE)

> IDs<-sapply(strsplit(state.map$names,":"),function(x)x[1])

> state.sp<-map2SpatialPolygons(state.map,IDs=IDs,

+ proj4string=CRS("+proj=longlat+ellps=WGS84"))

> sat<-read.table("C:/Users/Thomas
AUBINEAU/Desktop/state.sat.data_mod.txt",row.names=5,

+ header=TRUE)

> str(sat)

'data.frame':   52 obs. of  4 variables:

 $ oname : Factor w/ 52 levels "ala","alaska",..: 1 2 3 4 5 6 7 9 8 10 ...

 $ vscore: int  561 516 524 563 497 536 510 503 494 499 ...

 $ mscore: int  555 514 525 556 514 540 509 497 478 498 ...

 $ pc    : int  9 50 34 6 49 32 80 67 77 53 ...

> id<-match(row.names(sat),sapply(slot(state.sp,"polygons"),

+ function(x)slot(x,"ID")))

> row.names(sat)[is.na(id)]

[1] "alaska" "hawaii" "usa"   

> state.spdf<-SpatialPolygonsDataFrame(state.sp,sat)

Error: length(Sr@polygons) == nrow(data) is not TRUE

 

Thomas AUBINEAU

Responsable technique GDS 35

ZA Atalante Champeaux

35042 RENNES CEDEX

0223482600 / 0623258789

 


	[[alternative HTML version deleted]]

