Quantcast
Channel: Search Results for “maps”– R-bloggers
Viewing all articles
Browse latest Browse all 589

choroplethrZip v1.3.0: easier demographics, national maps

$
0
0

(This article was first published on Just an R Blog » R, and kindly contributed to R-bloggers)

Introduction

choroplethr v3.0 is now available on github. You can get it by typing

# install.packages("devtools")
library(devtools)
install_github('arilamstein/choroplethrZip@v1.3.0')

Version 1.3.0 has two new features:

  1. Data frame df_zip_demographics contains eight demographic statistics about each ZIP Code Tabulated Area (ZCTA) in the US. Data comes from the 2013 5-year American Community Survey (ACS).
  2. Function ?get_zip_demographics will return a data.frame with those same statistics from an arbitrary ACS.

Data

Here is how to access the data:

library(choroplethrZip)
data(df_zip_demographics)

?df_zip_demographics
colnames(df_zip_demographics)
 [1] "region" "total_population" "percent_white" 
 [4] "percent_black" "percent_asian" "percent_hispanic" 
 [7] "per_capita_income" "median_rent" "median_age"

summary(df_zip_demographics[, "total_population"])
 Min. 1st Qu. Median Mean 3rd Qu. Max. 
 0    721     2802   9517 13000   114700

Mapping the Data

Here is a program which will create national maps of the data:

# for each column in the data.frame
for (i in 2:ncol(df_zip_demographics))
{
 # set the value and title
 df_zip_demographics$value = df_zip_demographics[,i]
 title = paste0("2013 ZCTA Demographics:n",
                colnames(df_zip_demographics[i]))

 # print the map
 choro = zip_choropleth(df_zip_demographics, title=title)
 print(choro)
}

Note that national zip maps can take a few minutes to render. Here is the output.

total_population

percent_white

percent_black

percent_asian

percent_hispanic

per_capita_income

median_rent

median_age

New Vignette

Additionally, I have created a new vignette about these features.


To leave a comment for the author, please follow the link and comment on his blog: Just an R Blog » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

Viewing all articles
Browse latest Browse all 589

Trending Articles