[R-sig-Geo] maptools: appending data to SpatialPolygonsDataFrame
Roger.Bivand at nhh.no
Mon May 12 22:00:30 CEST 2008
On Tue, 29 Apr 2008, hkreft at ucsd.edu wrote:
> Dear all,
> I am just starting to use the library maptools. Specifically, I want to
> use it as a quick way to map results from various multivariate analyses
> (e.g. cluster analyses) directly in R.
> I encountered problems appending newly generated data (cluster
> memberships) to the SpatialPolygonsDataFrame object. Unfortunately, the
> documentation is not really helpful.
Sorry that this message did not get a reply - I'm afraid that your code
example is unhelpful, because it doesn't go far enough. Do you mean
xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools"),
IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
k5 <- kmeans(as(xx, "data.frame")[, 9:14], center=5)
xx$k5 <- factor(k5$cluster)
for a trivial example that can be reproduced?
> But I am sure that this is an easy question for you.
> Thanks in advance,
> The code so far:
>>> my.polys <- readShapePoly("Z://mypoly.shp",IDvar="ID",verbose=T)
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, 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
More information about the R-sig-Geo