Skip to content

Commit

Permalink
update documentation, better handle NULL countries for world map
Browse files Browse the repository at this point in the history
  • Loading branch information
alamstein-trulia committed Jun 14, 2014
1 parent b668263 commit 4c28753
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 4 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Title: Functions to simplify the creation of choropleths (thematic maps) in R.
Description: choroplethr simplifies the creation of choropleths in R. A
choropleth is a thematic map where geographic regions such as states are
colored according to some metric, such as which political party the state
voted for. choroplethr supports three levels of geographic resolution and
voted for. choroplethr supports four levels of geographic resolution and
two types of scales. Common problems such as matching county data with map
data, choosing and labeling discrete scales and creating a clean background
are handled automatically. choroplethr provides native support for viewing
data from the US Census's American Community Survey (ACS).
Version: 1.6.99
Version: 1.7.0
Author: Ari Lamstein <[email protected]>[cre, aut],
Brian P Johnson <[email protected]> [ctb, frontend animation code]
Maintainer: Ari Lamstein <[email protected]>
Expand Down
16 changes: 15 additions & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' @docType data
#' @references Taken from \url{http://www.fec.gov/pubrec/fe2012/federalelections2012.shtml} on 3/15/2014.
#' @keywords data
#' @usage data(choroplethr)
#' @examples
#' data(choroplethr)
#' choroplethr(df_president, "state", title="Results from the 2012 US Presidential Election")
Expand All @@ -16,6 +17,7 @@ NULL
#' @references Taken from the US American Community Survey (ACS) 5 year estimates with \link{get_acs_df} using table B01003.
#'
#' @keywords data
#' @usage data(choroplethr)
#' @examples
#' data(choroplethr)
#' choroplethr(df_pop_state, "state", title="2012 Population Estimates")
Expand All @@ -28,6 +30,7 @@ NULL
#' @references Taken from the US American Community Survey (ACS) 5 year estimates with \link{get_acs_df} using table B01003.
#'
#' @keywords data
#' @usage data(choroplethr)
#' @examples
#' data(choroplethr)
#' choroplethr(df_pop_state, "state", title="2012 Population Estimates")
Expand All @@ -42,6 +45,7 @@ NULL
#' @references Taken from the US American Community Survey (ACS) 5 year estimates with \link{get_acs_df} using table B01003.
#' ZCTAs, and their realationship to ZIP codes, are explained here \url{https://www.census.gov/geo/reference/zctas.html}.
#' @keywords data
#' @usage data(choroplethr)
#' @examples
#' data(choroplethr)
#' choroplethr(df_pop_state, "state", title="2012 Population Estimates")
Expand Down Expand Up @@ -75,6 +79,7 @@ NULL
#' @references Taken from \url{http://en.wikipedia.org/wiki/List_of_United_States_presidential_election_results_by_state} 3/20/2014.
#' @keywords data
#' @name df_president_ts
#' @usage data(choroplethr)
NULL

#' Map of the 50 US states plus the district of columbia.
Expand All @@ -87,6 +92,7 @@ NULL
#'
#' @docType data
#' @name map.states
#' @usage data(map.states)
#' @references Taken from the US Census 2010
#' Cartographic Boundary shapefiles page (https://www.census.gov/geo/maps-data/data/tiger-cart-boundary.html) in May 2014.
#' The resolutions is 20m (20m = 1:20,000,000).
Expand Down Expand Up @@ -132,6 +138,7 @@ NULL
#'
#' @docType data
#' @name map.counties
#' @usage data(map.counties)
#' @references Taken from the US Census 2010
#' Cartographic Boundary shapefiles page (https://www.census.gov/geo/maps-data/data/tiger-cart-boundary.html) in May 2014.
#' The resolutions is 20m (20m = 1:20,000,000).
Expand All @@ -142,6 +149,7 @@ NULL
#'
#' @docType data
#' @name state.names
#' @usage data(state.names)
#' @references Taken from http://www.epa.gov/envirofw/html/codes/state.html
NULL

Expand All @@ -150,21 +158,27 @@ NULL
#'
#' @docType data
#' @name county.names
#' @usage data(county.names)
NULL

#' Map of the world.
#' A world map
#'
#' This data.frame corresponds to version 2.0.0 of the "Admin 0 - Countries" map from naturalearthdata.com
#' The data.frame was modified by removing columns with non-ASCII characters. Also,
#' I added a column called "region" which is the the all lowercase version of the
#' column "sovereignt".
#'
#' Note that due to the resolution of the map (1:110m, or 1 cm=1,100 km), small countries are not
#' represented on this map. See ?country.names for a list of all countries represented on the map.
#'
#' @references Taken from http://www.naturalearthdata.com/downloads/110m-cultural-vectors/
#' @docType data
#' @name map.world
#' @usage data(map.world)
NULL

#' Names of all counties on the map.world data.frame
#' @name country.names
#' @usage data(country.names)
#' @docType data
NULL
3 changes: 3 additions & 0 deletions R/world.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ world_choropleth_auto = function(df,
data(country.names, package="choroplethr", envir=environment())
stopifnot(countries %in% country.names)
stopifnot(!any(duplicated(countries)))
} else {
data(country.names, package="choroplethr", envir=environment())
countries = country.names
}

df$region = tolower(df$region)
Expand Down
3 changes: 3 additions & 0 deletions man/country.names.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
\name{country.names}
\alias{country.names}
\title{Names of all counties on the map.world data.frame}
\usage{
data(country.names)
}
\description{
Names of all counties on the map.world data.frame
}
Expand Down
3 changes: 3 additions & 0 deletions man/county.names.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
\alias{county.names}
\title{A data.frame consisting of the name of each county in the US as well as the county FIPS code (as both a character and integer),
the state name (as both a full name and an abbreviation) as well as the state FIPS code (as both a character and an integer).}
\usage{
data(county.names)
}
\description{
A data.frame consisting of the name of each county in the US as well as the county FIPS code (as both a character and integer),
the state name (as both a full name and an abbreviation) as well as the state FIPS code (as both a character and an integer).
Expand Down
3 changes: 3 additions & 0 deletions man/df_pop_county.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
\name{df_pop_county}
\alias{df_pop_county}
\title{A data.frame containing population estimates for US Counties in 2012.}
\usage{
data(choroplethr)
}
\description{
A data.frame containing population estimates for US Counties in 2012.
}
Expand Down
3 changes: 3 additions & 0 deletions man/df_pop_state.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
\name{df_pop_state}
\alias{df_pop_state}
\title{A data.frame containing population estimates for US States in 2012.}
\usage{
data(choroplethr)
}
\description{
A data.frame containing population estimates for US States in 2012.
}
Expand Down
3 changes: 3 additions & 0 deletions man/df_pop_zip.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
\name{df_pop_zip}
\alias{df_pop_zip}
\title{A data.frame containing population estimates for US Zip Code Tabulated Areas (ZCTAs) in 2012.}
\usage{
data(choroplethr)
}
\description{
ZCTAs are intended to be roughly analogous to postal ZIP codes.
}
Expand Down
3 changes: 3 additions & 0 deletions man/df_president.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
\name{df_president}
\alias{df_president}
\title{A data.frame containing election results from the 2012 US Presidential election.}
\usage{
data(choroplethr)
}
\description{
A data.frame containing election results from the 2012 US Presidential election.
}
Expand Down
3 changes: 3 additions & 0 deletions man/df_president_ts.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
\name{df_president_ts}
\alias{df_president_ts}
\title{A data.frame containing all US presdiential election results from 1789 to 2012}
\usage{
data(choroplethr)
}
\description{
Legend:
\itemize{
Expand Down
3 changes: 3 additions & 0 deletions man/map.counties.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
\name{map.counties}
\alias{map.counties}
\title{Map of the counties of each of the 50 US states plus the district of columbia.}
\usage{
data(map.counties)
}
\description{
A data.frame which contains a map of all 50 US States plus
the District of Columbia. The shapefile
Expand Down
3 changes: 3 additions & 0 deletions man/map.states.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
\name{map.states}
\alias{map.states}
\title{Map of the 50 US states plus the district of columbia.}
\usage{
data(map.states)
}
\description{
A data.frame which contains a map of all 50 US States plus
the District of Columbia. The shapefile
Expand Down
9 changes: 8 additions & 1 deletion man/map.world.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@
\docType{data}
\name{map.world}
\alias{map.world}
\title{Map of the world.}
\title{A world map}
\usage{
data(map.world)
}
\description{
This data.frame corresponds to version 2.0.0 of the "Admin 0 - Countries" map from naturalearthdata.com
The data.frame was modified by removing columns with non-ASCII characters. Also,
I added a column called "region" which is the the all lowercase version of the
column "sovereignt".
}
\details{
Note that due to the resolution of the map (1:110m, or 1 cm=1,100 km), small countries are not
represented on this map. See ?country.names for a list of all countries represented on the map.
}
\references{
Taken from http://www.naturalearthdata.com/downloads/110m-cultural-vectors/
}
Expand Down
3 changes: 3 additions & 0 deletions man/state.names.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
\alias{state.names}
\title{A data.frame consisting of all 50 state names (plus the District of Columbia), postal codes,
and FIPS codes both as characters and numbers (i.e. with and without a leading 0).}
\usage{
data(state.names)
}
\description{
A data.frame consisting of all 50 state names (plus the District of Columbia), postal codes,
and FIPS codes both as characters and numbers (i.e. with and without a leading 0).
Expand Down

0 comments on commit 4c28753

Please sign in to comment.