Hello list,
I have a question concerning the [ operator for SPDF. Consider the
following example :
library(maptools)
xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
plot(xx, border="blue", axes=TRUE, las=1)
text(getSpPPolygonsLabptSlots(xx), labels=getSpPPolygonsIDSlots(xx), cex=0.6)
as(xx, "data.frame")[1:5, 1:6]
xxx <- xx[xx$SID74 < 2,]
The last line is equivalent to :
xxx <- xx[which(xx$SID74 < 2),]
I supposed that I can easily have the inverse selection by using '-' but
it does not work :
xxx <- xx[which(xx$SID74 < 2),]
returns the following error message :
Erreur dans validObject(.Object) : invalid class "SpatialPolygons"
object: length mismatch
I do not understand what is the problem (sp 0.9-8, R 2.4.0).
Thanks,