combine.data.shapefile {CARBayes}R Documentation

Combines a data frame with a shapefile to create a SpatialPolygonsDataFrame object.

Description

This function combines a data frame with a shapefile to create a SpatialPolygonsDataFrame object from the ‘sp’ package. The creation of this object allows the variables in the data frame to be mapped using the ‘spplot()’ function, and the neighbourhood matrix W to be created using the ‘poly2nb’ and ‘nb2mat’ functions. An example is given in the vignette accompanying this package. The mapping of the data to the shapefile is done by matching the rownames of the data frame to the first column in the dbf file.

Usage

combine.data.shapefile(data, shp, dbf)

Arguments

data

A data frame containing the variables relating to the K areas you wish to map or model. The row names of this data frame must appear in the first column of the dbf file.

shp

The .shp part of a shapefile containing the polygons for each of the K areas that the data relate to.

dbf

The .dbf part of the shapefile containing a lookup table whose first column should inlcude the K row names of the data frame.

Value

A SpatialPolygonsDataFrame object from the sp package containing the conbined data and shapefile object.

Author(s)

Duncan Lee

Examples

## See the vignette accompanying this package for an example of its use.

[Package CARBayes version 5.2.5 Index]