Set up testing code.

sapply(c('tidycensus','here','tidyverse'), require, character.only=T)
knitr::opts_knit$set(root.dir = here())

Set up testthat

usethis::use_testthat()

Actually test the package

devtools::test()

Check the package

devtools::check()

An example test

# by default, creates a vector. Note that each vector must be input manually
divergence(alameda_wide$white,alameda_wide$hispanic,alameda_wide$asian,alameda_wide$black, totalPop = alameda_wide$total_pop)

# if .sum==TRUE, creates a single number
divergence(alameda_wide$white,alameda_wide$hispanic,alameda_wide$asian,alameda_wide$black, totalPop = alameda_wide$total_pop, .sum=T)

Testing entropy

entropy(alameda_wide$white,alameda_wide$hispanic,alameda_wide$asian,alameda_wide$black, totalPop = alameda_wide$total_pop)


arthurgailes/rsegregation documentation built on May 23, 2021, 6:33 a.m.