You are currently in the GitHub repository (repo) for HW-4
. You must have completed all the steps in Setting Up.
- Working with choropleth maps in R
- Tackling a larger-scale more open-ended question
- Follow the same workflow as in HW-0 for HW-4.
- Do not submit a
HW-4.Rmd
file that does not knit. - I anticipate you spending between 8-12 total (across all submissions) on this homework.
- Use 2010 Census data; missing data should not be a problem except for Fairfax County, Virginia with FIPS Code 51059.
- One-dimensional center of mass.
- To get the centroids of all
n
polygons in aSpatialPolygons
class object in R usesp::coordinates()
, which returns an x 2
matrix where the first column is longitude and the second is latitude. You can assume that the order of the centroids matches the order ofcounties_sp@data
in the example below:
library(USAboundaries)
library(sp)
counties_sp <- us_counties()
centroids <- coordinates(counties_sp)
head(centroids)
## [,1] [,2]
## 0 -116.60176 48.29976
## 1 -85.42674 41.64232
## 2 -121.64454 45.51723
## 3 -97.69895 27.42438
## 4 -87.77990 36.03963
## 5 -97.85142 34.48557