- Notifications
You must be signed in to change notification settings - Fork2
Compute Diversity and Segregation Indices
License
Unknown, MIT licenses found
Licenses found
christopherkenny/divseg
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
divseg implements common measures of diversity (within-geography) andsegregation (across-geographies).
You can install the released version of divseg fromCRAN with:
install.packages("divseg")You can install the released version of divseg fromGitHub with:
pak::pak('christopherkenny/divseg')
The basic workflow relies on atibble where each row represents ageography and has columns that represent some form of population data.
library(divseg)#>#> Attaching package: 'divseg'#> The following object is masked from 'package:base':#>#> interaction
divseg comes with two example datasets.de_county contains 2010Census data on the counties in Delaware.de_tract likewise has 2010Census data on the tracts in Delaware.
data('de_county')data('de_tract')
A pretty standard function call returns a vector, where the first entryis atibble and the second istidyselect language.
ds_blau(.data=de_county,.cols= starts_with('pop_'))#> [1] 0.5155228 0.5570435 0.4052769
More importantly, if you specify an argument to.name, all functionsare pipe-able.
de_county|> ds_blau(starts_with('pop_'),.name='blau')|> ds_delta(starts_with('pop_'),.name='delta')|>dplyr::relocate(blau,delta)#> Simple feature collection with 3 features and 22 fields#> Geometry type: MULTIPOLYGON#> Dimension: XY#> Bounding box: xmin: -75.78866 ymin: 38.45101 xmax: -75.04894 ymax: 39.83901#> Geodetic CRS: NAD83#> # A tibble: 3 × 23#> blau delta GEOID NAME pop pop_white pop_black pop_hisp pop_aian pop_asian#> <dbl> <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>#> 1 0.516 0.345 10001 Kent… 162310 105891 37812 9346 916 3266#> 2 0.557 0.345 10003 New … 538479 331836 124426 46921 984 23132#> 3 0.405 0.345 10005 Suss… 197145 149025 24544 16954 924 1910#> # ℹ 13 more variables: pop_nhpi <dbl>, pop_other <dbl>, pop_two <dbl>,#> # vap <dbl>, vap_white <dbl>, vap_black <dbl>, vap_hisp <dbl>,#> # vap_aian <dbl>, vap_asian <dbl>, vap_nhpi <dbl>, vap_other <dbl>,#> # vap_two <dbl>, geometry <MULTIPOLYGON [°]>
Each function has a partner that can go inside calls todplyr::mutate() by dropping theds_ prefix:
de_county|>dplyr::mutate(herf= hhi(starts_with('pop_')))|>dplyr::relocate(herf)#> Simple feature collection with 3 features and 21 fields#> Geometry type: MULTIPOLYGON#> Dimension: XY#> Bounding box: xmin: -75.78866 ymin: 38.45101 xmax: -75.04894 ymax: 39.83901#> Geodetic CRS: NAD83#> # A tibble: 3 × 22#> herf GEOID NAME pop pop_white pop_black pop_hisp pop_aian pop_asian#> <dbl> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>#> 1 0.484 10001 Kent Count… 162310 105891 37812 9346 916 3266#> 2 0.443 10003 New Castle… 538479 331836 124426 46921 984 23132#> 3 0.595 10005 Sussex Cou… 197145 149025 24544 16954 924 1910#> # ℹ 13 more variables: pop_nhpi <dbl>, pop_other <dbl>, pop_two <dbl>,#> # vap <dbl>, vap_white <dbl>, vap_black <dbl>, vap_hisp <dbl>,#> # vap_aian <dbl>, vap_asian <dbl>, vap_nhpi <dbl>, vap_other <dbl>,#> # vap_two <dbl>, geometry <MULTIPOLYGON [°]>
About
Compute Diversity and Segregation Indices
Resources
License
Unknown, MIT licenses found
Licenses found
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.
