Browse Source

more data in the slot, better column names

master
hrbrmstr 8 years ago
parent
commit
2af88c5855
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 20
      R/albersusa.R
  2. 5
      README.Rmd
  3. 42
      README.html
  4. 49
      README.md
  5. BIN
      README_files/figure-html/unnamed-chunk-3-5.png
  6. 103
      inst/extdata/composite_us_states.geojson
  7. BIN
      inst/extdata/states.rda
  8. 21
      man/usa_composite.Rd

20
R/albersusa.R

@ -4,6 +4,26 @@
#' plotting. If anything but \code{longlat} is specified the composite map
#' will be pre-projected to those
#'
#' This is what's in the SPDF \code{@data} slot:
#'
#' \preformatted{
#' Observations: 51
#' Variables: 13
#' $ geo_id (chr) "0400000US04", "0400000US05", "0400000US06", "0400...
#' $ fips_state (chr) "04", "05", "06", "08", "09", "11", "13", "17", "1...
#' $ name (chr) "Arizona", "Arkansas", "California", "Colorado", "...
#' $ lsad (chr) "", "", "", "", "", "", "", "", "", "", "", "", ""...
#' $ census_area (dbl) 113594.084, 52035.477, 155779.220, 103641.888, 484...
#' $ iso_3166_2 (chr) "AZ", "AR", "CA", "CO", "CT", "DC", "GA", "IL", "I...
#' $ census (int) 6392017, 2915918, 37253956, 5029196, 3574097, 6017...
#' $ pop_estimataes_base (int) 6392310, 2915958, 37254503, 5029324, 3574096, 6017...
#' $ pop_2010 (int) 6411999, 2922297, 37336011, 5048575, 3579345, 6052...
#' $ pop_2011 (int) 6472867, 2938430, 37701901, 5119661, 3590537, 6204...
#' $ pop_2012 (int) 6556236, 2949300, 38062780, 5191709, 3594362, 6350...
#' $ pop_2013 (int) 6634997, 2958765, 38431393, 5272086, 3599341, 6491...
#' $ pop_2014 (int) 6731484, 2966369, 38802500, 5355866, 3596677, 6588...
#' }
#'
#' @param proj if anything but \code{longlat} is specified, the shapefile will
#' be pre-projected before being returned
#' @export

5
README.Rmd

@ -46,13 +46,16 @@ library(ggthemes)
packageVersion("albersusa")
us <- usa_composite()
(dplyr::glimpse(us@data))
plot(us)
us <- usa_composite("laea")
plot(us)
us <- usa_composite()
us_map <- fortify(us, region="NAME")
us_map <- fortify(us, region="name")
gg <- ggplot()
gg <- gg + geom_map(data=us_map, map=us_map,

42
README.html

File diff suppressed because one or more lines are too long

49
README.md

@ -45,21 +45,48 @@ packageVersion("albersusa")
```r
us <- usa_composite()
(dplyr::glimpse(us@data))
```
```
## Observations: 51
## Variables: 13
## $ geo_id (chr) "0400000US04", "0400000US05", "0400000US06", "0400000US08", "0400000US09", "0400000US11...
## $ fips_state (chr) "04", "05", "06", "08", "09", "11", "13", "17", "18", "22", "27", "28", "30", "35", "38...
## $ name (chr) "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "District of Columbia",...
## $ lsad (chr) "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",...
## $ census_area (dbl) 113594.084, 52035.477, 155779.220, 103641.888, 4842.355, 61.048, 57513.485, 55518.930, ...
## $ iso_3166_2 (chr) "AZ", "AR", "CA", "CO", "CT", "DC", "GA", "IL", "IN", "LA", "MN", "MS", "MT", "NM", "ND...
## $ census (int) 6392017, 2915918, 37253956, 5029196, 3574097, 601723, 9687653, 12830632, 6483802, 45333...
## $ pop_estimataes_base (int) 6392310, 2915958, 37254503, 5029324, 3574096, 601767, 9688681, 12831587, 6484192, 45334...
## $ pop_2010 (int) 6411999, 2922297, 37336011, 5048575, 3579345, 605210, 9714464, 12840097, 6490308, 45455...
## $ pop_2011 (int) 6472867, 2938430, 37701901, 5119661, 3590537, 620427, 9813201, 12858725, 6516560, 45759...
## $ pop_2012 (int) 6556236, 2949300, 38062780, 5191709, 3594362, 635040, 9919000, 12873763, 6537632, 46047...
## $ pop_2013 (int) 6634997, 2958765, 38431393, 5272086, 3599341, 649111, 9994759, 12890552, 6570713, 46292...
## $ pop_2014 (int) 6731484, 2966369, 38802500, 5355866, 3596677, 658893, 10097343, 12880580, 6596855, 4649...
```
```
## NULL
```
```r
plot(us)
```
<img src="README_files/figure-html/unnamed-chunk-3-1.png" width="672" />
<img src="README_files/figure-html/unnamed-chunk-3-1.png" title="" alt="" width="672" />
```r
us <- usa_composite("laea")
plot(us)
```
<img src="README_files/figure-html/unnamed-chunk-3-2.png" width="672" />
<img src="README_files/figure-html/unnamed-chunk-3-2.png" title="" alt="" width="672" />
```r
us <- usa_composite()
us_map <- fortify(us, region="NAME")
us_map <- fortify(us, region="name")
gg <- ggplot()
gg <- gg + geom_map(data=us_map, map=us_map,
@ -70,43 +97,43 @@ gg <- gg + theme_map()
gg + coord_map()
```
<img src="README_files/figure-html/unnamed-chunk-3-3.png" width="672" />
<img src="README_files/figure-html/unnamed-chunk-3-3.png" title="" alt="" width="672" />
```r
gg + coord_map("polyconic")
```
<img src="README_files/figure-html/unnamed-chunk-3-4.png" width="672" />
<img src="README_files/figure-html/unnamed-chunk-3-4.png" title="" alt="" width="672" />
```r
gg + coord_proj()
```
<img src="README_files/figure-html/unnamed-chunk-3-5.png" width="672" />
<img src="README_files/figure-html/unnamed-chunk-3-5.png" title="" alt="" width="672" />
```r
gg + coord_proj(us_laea_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-6.png" width="672" />
<img src="README_files/figure-html/unnamed-chunk-3-6.png" title="" alt="" width="672" />
```r
gg + coord_proj(us_aeqd_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-7.png" width="672" />
<img src="README_files/figure-html/unnamed-chunk-3-7.png" title="" alt="" width="672" />
```r
gg + coord_proj(us_eqdc_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-8.png" width="672" />
<img src="README_files/figure-html/unnamed-chunk-3-8.png" title="" alt="" width="672" />
```r
gg + coord_proj(us_lcc_proj)
```
<img src="README_files/figure-html/unnamed-chunk-3-9.png" width="672" />
<img src="README_files/figure-html/unnamed-chunk-3-9.png" title="" alt="" width="672" />
### Test Results
@ -119,7 +146,7 @@ date()
```
```
## [1] "Mon Mar 28 16:25:47 2016"
## [1] "Mon Mar 28 17:45:26 2016"
```
```r

BIN
README_files/figure-html/unnamed-chunk-3-5.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

103
inst/extdata/composite_us_states.geojson

File diff suppressed because one or more lines are too long

BIN
inst/extdata/states.rda

Binary file not shown.

21
man/usa_composite.Rd

@ -15,6 +15,27 @@ The \code{proj} parameter is intende to simplify usage for those using base
plotting. If anything but \code{longlat} is specified the composite map
will be pre-projected to those
}
\details{
This is what's in the SPDF \code{@data} portion:
\preformatted{
Observations: 51
Variables: 13
$ geo_id (chr) "0400000US04", "0400000US05", "0400000US06", "0400...
$ fips_state (chr) "04", "05", "06", "08", "09", "11", "13", "17", "1...
$ name (chr) "Arizona", "Arkansas", "California", "Colorado", "...
$ lsad (chr) "", "", "", "", "", "", "", "", "", "", "", "", ""...
$ census_area (dbl) 113594.084, 52035.477, 155779.220, 103641.888, 484...
$ iso_3166_2 (chr) "AZ", "AR", "CA", "CO", "CT", "DC", "GA", "IL", "I...
$ census (int) 6392017, 2915918, 37253956, 5029196, 3574097, 6017...
$ pop_estimataes_base (int) 6392310, 2915958, 37254503, 5029324, 3574096, 6017...
$ pop_2010 (int) 6411999, 2922297, 37336011, 5048575, 3579345, 6052...
$ pop_2011 (int) 6472867, 2938430, 37701901, 5119661, 3590537, 6204...
$ pop_2012 (int) 6556236, 2949300, 38062780, 5191709, 3594362, 6350...
$ pop_2013 (int) 6634997, 2958765, 38431393, 5272086, 3599341, 6491...
$ pop_2014 (int) 6731484, 2966369, 38802500, 5355866, 3596677, 6588...
}
}
\examples{
plot(usa_composite())

Loading…
Cancel
Save