county: Selects one or more counties in a given state

Description Usage Arguments Value Warning Author(s) References Examples

Description

county allows the user to pull out the polygon and metadata of one or more county(s) from a given state.

Usage

1
2
3
county(fips = NULL, name = NULL, state, 

level = c("tract", "blk", "blkgrp"), statefips = FALSE, sp.object=NULL, proj=NULL)

Arguments

fips

a character string, takes a string of three characters (i.e. a county FIPS code (e.g. "001").

name

a character string, this must be the name of an actual county in the state (e.g. "Baker" county Oregon). This variable is insensitive to case.

state

a character string, can either be the full name (e.g. "oregon"), the abbreviation (e.g. "or"), or the FIPS code (e.g. "41")– note that if you are using the FIPS code you have to change statefips to TRUE. This variable is insensitive to case.

level

a character string, takes in one of three values: "tract", "blk", or "blkgrp". This defines the geographic level of data for the county.

statefips

logical, by default statefips=FALSE, change to TRUE when providing state with a FIPS code.

sp.object

SpatialPolygonsDataFrame, default NULL, allows the user to provide an sp object in which to perform this operation; primarily for use with demographics.add.

proj

CRS-class, takes a CRS object (e.g. CRS("+proj=utm +zone=10 +datum=NAD83") ); This is simply a wrapper for the spTransform function in rgdal . WARNING requires rgdal package.

Value

An object of class SpatialPolygonsDataFrame.

Warning

You must have the packages UScensus2010tract, UScensus2010blkgrp and UScensus2010blk installed to use levels "tract", "blkgrp" and "blk" respectively.

Author(s)

Zack W. Almquist almquist@uci.edu

References

Zack W. Almquist (2010). US Census Spatial and Demographic Data in R: The UScensus2000 Suite of Packages. Journal of Statistical Software, 37(6), 1-31. http://www.jstatsoft.org/v37/i06/.

Census 2010 Summary File 1 [name of state1 or United States]/prepared by the U.S. Census Bureau, 2011.
http://www.census.gov/prod/cen2010/doc/sf1.pdf

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
#### look at the counties of Oregon
data(countyfips)
countyfips[countyfips$statename=="oregon",]

### The county fips code is the last three characters
county.f<-"001"
county.n<-c("deschutes","crook county")

## Pull out these counties
c1<-county(fips=county.f,state="or",level="tract")
c2<-county(name=county.n,state="or",level="tract")

##Plot counties
oregon.counties<-countyfips[countyfips$statename=="oregon",]
col<-cbind(c("red","blue"),c("013","017"))
plot(c2,col=col[match(c2$county,col[,2]),1],border="gray")
title("Deschutes and Crook counties, OR 2000")
coord<-coordinates(c2)
text(coord[c(1,4),],oregon.counties$countyname[oregon.counties$countyname%in%county.n],cex=2)

## End(Not run)

zalmquist/UScensus2010 documentation built on May 4, 2019, 9:08 p.m.