sp_tidiers {broom} | R Documentation

## 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 class 'SpatialPolygonsDataFrame'
    tidy(x, region = NULL, ...)

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

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

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

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

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

    ## S3 method for class '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

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

[Package broom version 0.4.2 Index]