Learn R Programming

eeptools (version 0.9.1)

mapmerge: Combine an S4 polygon object with a dataframe

Description

Convenience function for merging dataframes and S4 spatial polygon objects.

Usage

mapmerge(mapobj, data, xid, yid)

Arguments

mapobj
Name of an S4 SpatialPolygonsDataFrame
data
Name of a dataframe
xid
Name of ID variable in the SpatialPolygonsDataFrame
yid
Name of ID variable in the dataframe

Value

A SpatialPolygonsDataFrame with new variables attached from supplied dataframe

Examples

Run this code
## Not run: 
# xx <- maptools::readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], IDvar="FIPSNO")
# yy <- as(xx,"data.frame")
# yy$newvar <- sample(letters, nrow(yy), replace=TRUE)
# yy <- subset(yy, select=c("FIPS", "newvar"))
# newpoly <- mapmerge(xx, yy, xid="FIPS", yid="FIPS")
# ## End(Not run)

Run the code above in your browser using DataLab