An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20130710/2a1200d1/attachment.pl>
length polygons / nrow data
3 messages · Thomas AUBINEAU, Roger Bivand, Michael Blows
On Wed, 10 Jul 2013, Thomas AUBINEAU wrote:
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).
Assuming that you did download the code for that chapter (2, 1st edition I assume) from http://www.asdar-book.org/book/cm_mod.R, are you in chunk 73? All the code is run daily, so it does work; for future reference, please paste the offending line of code and error message into your question. Roger
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 at polygons) == nrow(data) is not TRUE Thomas AUBINEAU Responsable technique GDS 35 ZA Atalante Champeaux 35042 RENNES CEDEX 0223482600 / 0623258789 [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Department of Economics, NHH Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no
3 days later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20130713/27dc0905/attachment.pl>