MyNixOS website logo
Description

Score Redistricting Plans with 'PlanScore'.

Provides access to the 'PlanScore' Application Programming Interface (<https://github.com/PlanScore/PlanScore/blob/main/API.md>) for scoring redistricting plans. Allows for upload of plans from block assignment files and shape files. For shapes in memory, such as from 'sf' or 'redist', it processes them to save and upload. Includes tools for tidying responses and saving output from the website.

planscorer

R-CMD-check planscorer statusbadge Lifecycle:stable CRANstatus CRANdownloads

planscorer offers an R interface to PlanScore.org’s API.

Installation

You can install the stable version of planscorer from CRAN with:

install.packages('planscorer')

You can install the development version of planscorer from GitHub with:

# install.packages('remotes')
remotes::install_github('christopherkenny/planscorer')

Authentication

To use planscorer, you must have an API key from PlanScore. Otherwise, you will get a 403 forbidden error.

To get a key, follow the instructions here.

Once you have a key, use ps_set_key('your_key'). Optionally use ps_set_key('your_key', install = TRUE) to allow your key to be available across sessions.

Example

With a file, you can upload using the ps_upload_file() option:

library(planscorer)
## basic example code

file <- system.file('extdata/null-plan-incumbency.geojson', package = 'planscorer')
links <- ps_upload_file(file)
#> ℹ Using single-step upload.

To read the data results:

ps_ingest(links)
#> # A tibble: 2 × 62
#>   district democratic_votes democratic_votes_sd democratic_wins republican_votes
#>   <chr>               <dbl>               <dbl>           <dbl>            <dbl>
#> 1 1                    155.                29.9           0                 445.
#> 2 2                    379.                29.6           0.998             221.
#> # ℹ 57 more variables: republican_votes_sd <dbl>, us_president_2016_dem <dbl>,
#> #   us_president_2016_rep <dbl>, district_number <int>, polsby_popper <dbl>,
#> #   reock <dbl>, declination <dbl>, declination_absolute_percent_rank <dbl>,
#> #   declination_is_valid <dbl>, declination_positives <dbl>,
#> #   declination_relative_percent_rank <dbl>, declination_sd <dbl>,
#> #   efficiency_gap <dbl>, efficiency_gap_1_dem <dbl>,
#> #   efficiency_gap_1_dem_sd <dbl>, efficiency_gap_1_rep <dbl>, …

To capture the outputted figures on the site:

img <- 'man/figures/README-planscore.png'
ps_capture(links, img)
#> https://planscore.org/plan.html?temporary-bd7843f2-9dfa-4c80-9b63-3400e77dab18 screenshot completed
#> [1] "man/figures/README-planscore.png"

knitr::include_graphics(img)
Metadata

Version

0.0.3

License

Unknown

Platforms (76)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows