Learn R Programming

broom (version 0.4.3)

sp_tidiers: tidying methods for classes from the sp package.

Description

Tidy classes from the sp package to allow them to be plotted using ggplot2. To figure out the correct variable name for region, inspect as.data.frame(x).

Usage

# S3 method for SpatialPolygonsDataFrame
tidy(x, region = NULL, ...)

# S3 method for SpatialPolygons tidy(x, ...)

# S3 method for Polygons tidy(x, ...)

# S3 method for Polygon tidy(x, ...)

# S3 method for SpatialLinesDataFrame tidy(x, ...)

# S3 method for Lines tidy(x, ...)

# S3 method for Line tidy(x, ...)

Arguments

x

SpatialPolygonsDataFrame to convert into a dataframe.

region

name of variable used to split up regions

...

not used by this method

Details

These functions originated in the ggplot2 package as "fortify" functions.

Examples

Run this code
# NOT RUN {
if (require("maptools")) {
    sids <- system.file("shapes/sids.shp", package="maptools")
    nc1 <- readShapePoly(sids,
    proj4string = CRS("+proj=longlat +datum=NAD27"))
    nc1_df <- tidy(nc1)
}

# }

Run the code above in your browser using DataLab