Skip to content

Commit

Permalink
CRAN fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CoryMcCartan committed Jun 10, 2024
1 parent 8befe41 commit bb30516
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 27 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: birdie
Title: Bayesian Instrumental Regression for Disparity Estimation
Version: 0.6.0
Version: 0.6.1
Authors@R: c(
person("Cory", "McCartan", role=c("aut", "cre"), email="mccartan@psu.edu"),
person("Kosuke", "Imai", role="ctb", email="imai@harvard.edu"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ importFrom(stringr,str_remove)
importFrom(stringr,str_remove_all)
importFrom(stringr,str_replace_all)
importFrom(stringr,str_starts)
importFrom(utils,capture.output)
importFrom(utils,head)
importFrom(utils,packageVersion)
importFrom(utils,relist)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# birdie 0.6.0
# birdie 0.6.1

* Switch to an inverse-gamma prior for the random effects scale parameter in
the mixed model.
Expand Down
2 changes: 1 addition & 1 deletion R/birdie-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @importFrom stats weighted.mean rnorm rgamma median sd cov dnorm optim
#' @importFrom stats terms get_all_vars model.frame model.matrix setNames
#' @importFrom stats formula update.formula as.formula nobs family vcov residuals
#' @importFrom utils tail unstack relist head packageVersion
#' @importFrom utils tail unstack relist head packageVersion capture.output
#' @importFrom graphics barplot par arrows
#' @importFrom grDevices colorRampPalette
#' @useDynLib birdie, .registration=TRUE
Expand Down
13 changes: 6 additions & 7 deletions R/bisg.R
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,13 @@ make_gx_tbl_vec <- function(vars, p_r, p_rgx) {

# if there is just one ID column we can easily fill in "<none>"
if (length(GX_names) > 1) {
d_miss <- anti_join(vars$GX, p_rgx, by=names(vars$GX))
d_miss <- distinct(anti_join(vars$GX, p_rgx, by=names(vars$GX)))
if (nrow(d_miss) > 0) {
cli::cli_text("Missing from {.arg p_rgx}:")
print(head(d_miss, 10))
if (nrow(d_miss) > 10) cat("...")
cli_abort("Some predictor combinations are missing from {.arg p_rgx}.",
call=parent.frame())
str_miss = capture.output(head(d_miss, 10))
if (nrow(d_miss) > 10) str_miss = c(str_miss, " ...")
msg = c("Some predictor combinations are missing from {.arg p_rgx}:", str_miss) |>
str_replace_all(" ", "\ua0")
rlang::abort(msg, use_cli_format=TRUE, call=parent.frame())
}
}
}
Expand Down Expand Up @@ -419,7 +419,6 @@ make_gx_tbl_vec <- function(vars, p_r, p_rgx) {
p_gxr[, i] = p_gxr[, i] / sum(p_gxr[, i])
}


if (est_p_r) {
p_r = colSums(p_rgx)
p_r = p_r / sum(p_r)
Expand Down
17 changes: 10 additions & 7 deletions R/census.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#'
#' Downloads and prepares race-by-geography tables from U.S. census data, using
#' the [`easycensus`][easycensus::easycensus] package. Requires that an api key
#' be set up through [easycensus::cens_auth()] in that package. Supports data
#' from the decennial census and the American Community Survey at a variety of
#' levels of geographic detail. The output of this function can be used directly
#' in [bisg()].
#' be set up through [easycensus::cens_auth()] in that package, usually by
#' storing it in the `CENSUS_API_KEY` environment variable. Supports data from
#' the decennial census and the American Community Survey at a variety of levels
#' of geographic detail. The output of this function can be used directly in
#' [bisg()].
#'
#' @param geo The geographic level to return. Common options are listed in the
#' function signature, but any of the geographies listed at
Expand All @@ -26,11 +27,13 @@
#' `white`, `black`, etc. containing the counts or proportion of
#' residents in each racial group.
#'
#' @examples \dontrun{
#' @examples
#' census_race_geo_table("zcta", year=2010)
#' \dontrun{
#' # Census API key required
#' census_race_geo_table("us", year=2010)
#' census_race_geo_table("state", year=2021, survey="acs1")
#' census_race_geo_table("state", year=2021, survey="acs1", GEOIDs=FALSE)
#' }
#' census_race_geo_table("state", year=2021, survey="acs1", GEOIDs=FALSE) }
#' @concept preproc
#' @export
census_race_geo_table <- function(geo=c("us", "state", "county", "zcta", "tract"),
Expand Down
13 changes: 9 additions & 4 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@

0 errors | 0 warnings | 2 notes

* This is a new release.
* This is a resubmission of a new release.

* GNU make is a SystemRequirement in order to compile Stan models.

* C++17 is a requirement in order to compile Stan models as well.
This is noted in src/Makevars and in SystemRequirements.

* Examples are \dontrun{} in census_race_geo_table() since they require an API
key and may take some time to run. This function is tested locally in
tests/testthat/test-census.R.
* Three examples are \dontrun{} in census_race_geo_table() since they require an
API key. Since last submission, the API key requirement is now documented in
the examples, not just in the function documentation. This function is tested
locally in tests/testthat/test-census.R.

* Examples are \donttest{} in birdie() since they generally take more than 5
seconds to run.

* I have removed the use of cat() to print additional error information in
bisg.R that was flagged on previous submission.
14 changes: 8 additions & 6 deletions man/census_race_geo_table.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bb30516

Please sign in to comment.