diff --git a/DESCRIPTION b/DESCRIPTION index 2b606efc..ed053a54 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,10 +17,10 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.1 Biarch: true Depends: - R (>= 3.4.0) + R (>= 4.0) Imports: spdep (>= 1.1-8), - sf, + sf (>= 1.0-10), ggplot2 (>= 3.0.0), methods, graphics, diff --git a/R/data.R b/R/data.R index aba2ad87..0dd70dad 100644 --- a/R/data.R +++ b/R/data.R @@ -57,9 +57,9 @@ #' Mullen, Lincoln A. and Bratt, Jordon. "USABoundaries: Historical and Contemporary Boundaries of the United States of America," #' Journal of Open Source Software 3, no. 23 (2018): 314, \doi{10.21105/joss.00314}. #' -#' @description A spatial polygons data frame of historical 1910 county boundaries of Florida with aggregated state prison sentencing counts and census data. +#' @description Simple features (`sf`) with historic (1910) county boundaries of Florida with aggregated state prison sentencing counts and census data. #' Sentencing and population counts are aggregates over the period 1905-1910, where populations were interpolated linearly between decennial censuses of 1900 and 1910. -#' @format A spatial polygons data frame with the following attributes: +#' @format Simple features (`sf`)/`data.frame` with the following attributes: #' \describe{ #' \item{name}{County name} #' \item{wpop}{White population total for years 1905-1910} diff --git a/R/stan_esf.R b/R/stan_esf.R index 7b51ad99..9eb10117 100644 --- a/R/stan_esf.R +++ b/R/stan_esf.R @@ -175,18 +175,17 @@ #' log.SSR <- log( SSR, base = 2 ) #' #' # map the log-SSRs -#' st_as_sf(sentencing) %>% -#' ggplot() + -#' geom_sf(aes(fill = log.SSR)) + -#' scale_fill_gradient2( -#' midpoint = 0, -#' name = NULL, -#' breaks = seq(-3, 3, by = 0.5) +#' ggplot(sentencing) + +#' geom_sf(aes(fill = log.SSR)) + +#' scale_fill_gradient2( +#' midpoint = 0, +#' name = NULL, +#' breaks = seq(-3, 3, by = 0.5) +#' ) + +#' labs(title = "Log-Standardized Sentencing Ratios", +#' subtitle = "log( Fitted/Expected ), base 2" #' ) + -#' labs(title = "Log-Standardized Sentencing Ratios", -#' subtitle = "log( Fitted/Expected ), base 2" -#' ) + -#' theme_void() +#' theme_void() #' } #' @export #' @md diff --git a/R/stan_icar.R b/R/stan_icar.R index c5564174..e70500ae 100644 --- a/R/stan_icar.R +++ b/R/stan_icar.R @@ -232,7 +232,7 @@ #' SSR <- f / sentencing$expected_sents #' log.SSR <- log( SSR, base = 2) #' -#' ggplot( st_as_sf(sentencing) ) + +#' ggplot(sentencing) + #' geom_sf(aes(fill = log.SSR)) + #' scale_fill_gradient2( #' low = "navy", diff --git a/data-raw/sentencing-data.R b/data-raw/sentencing-data.R index 78e845f4..d3a416cf 100644 --- a/data-raw/sentencing-data.R +++ b/data-raw/sentencing-data.R @@ -1,9 +1,11 @@ # download sf file with Florida counties and state prison sentencing data, 1905-1910 library(readr) +library(sf) tf <- tempfile(fileext = ".rds") download.file("https://github.com/ConnorDonegan/convict-leasing/raw/master/data/constructed/florida-1910-sp.rds", tf) fl <- read_rds(tf) fl@data <- fl@data[, c("name", "wpop", "bpop", "sents", "plantation_belt", "pct_ag_1910", "expected_sents")] fl@data$sir_raw <- with(fl@data, sents / expected_sents) -sentencing <- fl +sentencing <- st_as_sf(fl) usethis::use_data(sentencing, overwrite = TRUE) + diff --git a/data/sentencing.rda b/data/sentencing.rda index 322c479e..a17eaa2d 100644 Binary files a/data/sentencing.rda and b/data/sentencing.rda differ