Skip to content
Prev 23243 / 29559 Next

Spatialpolygonsdataframe

Hi

I tried to use sp merge to join the spatialpolygonddataframe (xx) and an
dataframe (yy4), which have 2 observations for each spatial ID. But it did
not allow with an error message as below:
 Error in .local(x, y, ...) :  'y' has multiple records for one or more
'by.y' key(s)

I also tried the mapmerge in eeptools but failed.

Any suggestion? Thank you very much.

Meta


library("eeptools")
library("sp")
xx <- maptools::readShapePoly(system.file("shapes/sids.shp",
package="maptools")[1], IDvar="FIPSNO")
yy<-as(xx,"data.frame")
yy$newvar<-sample(0:100,nrow(yy),replace=TRUE)
yy<-subset(yy,select=c("FIPS","newvar"))
yy3<-yy
yy3$newvar<-10*yy3$newvar
yy4<-data.frame(rbind(yy,yy3))
newpoly<-merge(xx,yy4,sort=FALSE, by.x="FIPS",
                  by.y="FIPS" ,all.y=TRUE)


On Tue, Aug 18, 2015 at 7:31 PM, Metastate Metastate <metastate at gmail.com>
wrote: