Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Compute Diversity and Segregation Indices

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

christopherkenny/divseg

Repository files navigation

CRAN statusR-CMD-checkLifecycle: stabledivseg status badge

divseg implements common measures of diversity (within-geography) andsegregation (across-geographies).

Installation

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')

Example

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

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp