Skip to content
Prev 23246 / 29559 Next

Spatialpolygonsdataframe

On Wed, 19 Aug 2015, Metastate Metastate wrote:

            
Thanks for a reproducible example. Don't use merge() unless you know 
already that the objects are conformable:
Look at str(yy4) and dim(xx) - they are not conformable. Add a "time" 
variable and use reshape() to get to a conformable object:

yy4$time <- c(rep(1, 100), rep(2, 100))
yy4a <- reshape(yy4, direction="wide", idvar="FIPS", timevar="time")

str(yy4a)

and combine:

library(maptools)
xxx <- spCbind(xx, yy4a)
summary(xxx)
spplot(xxx, c("newvar.1", "newvar.2"))

Note that the SIDS dataset is already in thw "wide" format with data from 
1974 and 1979 as columns. Read up on the long and wide formats, and maybe 
look at the documentation of the spacetime package.

Roger