diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..c7929d5 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,52 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + +name: R-CMD-check.yaml + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: macos-latest, r: 'release'} + - {os: windows-latest, r: 'release'} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + RGL_USE_NULL: true + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::rcmdcheck + needs: check + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/workflows/r.yml b/.github/workflows/r.yml deleted file mode 100644 index 2f19a0d..0000000 --- a/.github/workflows/r.yml +++ /dev/null @@ -1,101 +0,0 @@ -on: - push: - branches: - - main - pull_request: - branches: - - main - -name: R-CMD-check - -jobs: - R-CMD-check: - runs-on: ${{ matrix.config.os }} - - name: ${{ matrix.config.os }} (${{ matrix.config.r }}) - - strategy: - fail-fast: false - matrix: - config: - - {os: macOS-latest, r: 'devel'} - - {os: macOS-latest, r: 'release'} - - {os: macOS-latest, r: 'oldrel'} - - {os: windows-latest, r: 'devel'} - - {os: windows-latest, r: 'release'} - - {os: windows-latest, r: 'oldrel'} - - {os: ubuntu-latest, r: 'devel'} - - {os: ubuntu-latest, r: 'release'} - - {os: ubuntu-latest, r: 'oldrel'} - - env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - RSPM: ${{ matrix.config.rspm }} - R_FUTURE_PLAN: ${{ matrix.config.future_plan }} - - steps: - - uses: actions/checkout@v3 - - - uses: r-lib/actions/setup-r@v2 - with: - r-version: ${{ matrix.config.r }} - - - uses: r-lib/actions/setup-pandoc@v2 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - shell: Rscript {0} - - - name: Cache R packages - if: runner.os != 'Windows' - uses: actions/cache@v3 - with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-r-${{ matrix.config.r }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-1- - - # - name: "[Linux] Install required system libs" - # if: runner.os == 'Linux' - # run: sudo apt install libcurl4-openssl-dev libgit2-dev - # - # - name: "[Custom block] [Linux] Install spatial libraries" - # if: runner.os == 'Linux' - # run: sudo apt-get install libgdal-dev libproj-dev libgeos-dev libudunits2-dev - - # Try to automatically check for system dependencies and install them - # Note: this might not catch all required system libs and manual action might be needed - # - name: "[Stage] [Linux] Install linux system dependencies" - # if: runner.os == 'Linux' - # run: | - # while read -r cmd - # do - # eval sudo $cmd - # done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') - - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("rcmdcheck") - shell: Rscript {0} - - # # this section again is for sf - # - name: Install rgdal with configure - # if: runner.os == 'macOS' - # run: | - # install.packages("rgdal", type = "source", configure.args = "--with-proj-lib=/usr/local/lib/ --with-proj-include=/usr/local/include/") - # shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_: false - run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@v3 - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 4f63fc2..dee0ae5 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 1.0.12 -Date: 2024-10-07 18:00:19 UTC -SHA: 1802077891d79bc7df8b64a7d51448970b34ea27 +Version: 1.0.14 +Date: 2025-01-09 03:31:52 UTC +SHA: a9b8be8e63c000ea11d43be156e4b17770fa9c21 diff --git a/DESCRIPTION b/DESCRIPTION index b309bec..5debd04 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,12 +1,12 @@ Package: rdss Title: Companion Datasets and Functions for Research Design in the Social Sciences -Version: 1.0.12 +Version: 1.0.14 Authors@R: c(person("Graeme", "Blair", email = "graeme.blair@gmail.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9164-2102")), person("Alexander", "Coppock", email = "acoppock@gmail.com", role = c("aut"), comment = c(ORCID = "0000-0002-5733-2386")), person("Macartan", "Humphreys", email = "macartan@gmail.com", role = c("aut"), comment = c(ORCID = "0000-0001-7029-2326"))) Description: Helper functions to accompany the Blair, Coppock, and Humphreys (2022) "Research Design in the Social Sciences: Declaration, Diagnosis, and Redesign" . 'rdss' includes datasets, helper functions, and plotting components to enable use and replication of the book. -Imports: dplyr, rlang (>= 1.0.0), generics, ggplot2, tibble, tidyr, dataverse, readr, marginaleffects, broom, purrr, estimatr, randomizr +Imports: dplyr, rlang (>= 1.0.0), generics, ggplot2, tibble, tidyr, dataverse, readr, broom, purrr, estimatr, randomizr License: MIT + file LICENSE Encoding: UTF-8 LazyData: true @@ -17,6 +17,7 @@ Suggests: rdrobust, DIDmultiplegt, broom.mixed, + marginaleffects, grf, CausalQueries, metafor, diff --git a/NAMESPACE b/NAMESPACE index 3258d65..cd61cf6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -53,7 +53,6 @@ importFrom(ggplot2,element_text) importFrom(ggplot2,margin) importFrom(ggplot2,theme) importFrom(ggplot2,theme_minimal) -importFrom(marginaleffects,predictions) importFrom(purrr,as_vector) importFrom(purrr,map) importFrom(purrr,map_chr) diff --git a/NEWS.md b/NEWS.md index e3c58ce..b1ce05c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# rdss 1.0.14 + +* fixes issue with intermittent test failure +* deprecates tidy_stan in favor of new broom.mixed::tidy function + # rdss 1.0.12 * address bugs with future package diff --git a/R/get_replication_file.R b/R/get_replication_file.R index d2c5cfe..0c50f16 100644 --- a/R/get_replication_file.R +++ b/R/get_replication_file.R @@ -157,7 +157,7 @@ #' #' @examples #' -#' \donttest{ +#' \dontrun{ #' # Requires internet access #' if(curl::has_internet()) { #' diagnosis_2.1 <- get_rdss_file("diagnosis_2.1") diff --git a/R/helpers-multilevel-regression-poststratification.R b/R/helpers-multilevel-regression-poststratification.R index 737801d..f6ed7a6 100644 --- a/R/helpers-multilevel-regression-poststratification.R +++ b/R/helpers-multilevel-regression-poststratification.R @@ -13,13 +13,18 @@ #' #' @export #' -#' @importFrom marginaleffects predictions #' @importFrom dplyr group_by summarize #' @importFrom stats weighted.mean #' @importFrom rlang `!!` enquo #' post_stratification_helper <- function(model_fit, data, group, weights) { - predictions( + + if(!requireNamespace("marginaleffects")){ + message("The post_stratification_helper function requires the 'marginaleffects' package.") + return(invisible()) + } + + marginaleffects::predictions( model_fit, newdata = data, type = "response", diff --git a/R/helpers-stanreg.R b/R/helpers-stanreg.R index d759999..fd4eaf0 100644 --- a/R/helpers-stanreg.R +++ b/R/helpers-stanreg.R @@ -2,35 +2,29 @@ #' Tidy results from a stanreg regression and exponentiate the estimated coefficient #' -#' Note no standard errors or other summary statistics are provided +#' This function is deprecated. Please use the 'tidy' function from the 'broom.mixed' package. #' #' See https://book.declaredesign.org/choosing-an-answer-strategy.html#bayesian-formalizations #' #' @param x A stanreg fit from stan_glm #' @param conf.int Logical indicating whether or not to include a confidence interval in the tidied output. Defaults to FALSE. #' @param conf.level The confidence level to use for the confidence interval if conf.int = TRUE. Must be strictly greater than 0 and less than 1. Defaults to 0.95, which corresponds to a 95 percent confidence interval. -#' @param exponentiate Logical indicating whether or not to exponentiate the the coefficient estimates. Defaults to FALSE. Note that standard errors are not included when \code{exponentiate = TRUE}. +#' @param exponentiate Logical indicating whether or not to exponentiate the the coefficient estimates. Defaults to FALSE. #' @param ... Other arguments to broom.mixed::tidy #' #' @return data.frame of results #' #' @export tidy_stan <- function(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...) { + + message("This function is deprecated. Please use the 'tidy' function from the 'broom.mixed' package.") + if(!requireNamespace("broom.mixed")){ - message("The tidy_exponentiate function requires the 'broom.mixed' package.") + message("The tidy_stan function requires the 'broom.mixed' package.") return(invisible()) } - ret <- broom.mixed::tidy(x, conf.int = conf.int, conf.level = conf.level, ...) - - if (exponentiate) { - ret$estimate <- exp(ret$estimate) - if("conf.low" %in% colnames(ret)){ - ret$conf.low <- exp(ret$conf.low) - ret$conf.high <- exp(ret$conf.high) - } - ret$std.error <- NULL - } + ret <- broom.mixed::tidy(x, conf.int = conf.int, conf.level = conf.level, exponentiate = exponentiate, ...) ret } diff --git a/cran-comments.md b/cran-comments.md index 5318252..978c751 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,13 +1,13 @@ ## Submission -rdss 1.0.10 was archived off CRAN, principally because the `prediction` package was archived. This version switches to the `marginaleffects` package. +rdss 1.0.12 was archived off CRAN, due to an issue which was intermittent in the Additional_issues on CRAN. This has been fixed. ## Test environments * local OS X install (release) * ubuntu on github actions (devel, release, oldrel) -* windows on github actions (devel, release, oldrel) -* OS X on Github actions (devel, release, oldrel) +* windows on github actions (release) +* OS X on Github actions (release) * win-builder (devel, release, oldrel) ## R CMD check results diff --git a/man/get_rdss_file.Rd b/man/get_rdss_file.Rd index 437141c..c0c5646 100644 --- a/man/get_rdss_file.Rd +++ b/man/get_rdss_file.Rd @@ -163,7 +163,7 @@ diagnosis_23a \cr } \examples{ -\donttest{ +\dontrun{ # Requires internet access if(curl::has_internet()) { diagnosis_2.1 <- get_rdss_file("diagnosis_2.1") diff --git a/man/tidy_stan.Rd b/man/tidy_stan.Rd index 9b518b3..2952dda 100644 --- a/man/tidy_stan.Rd +++ b/man/tidy_stan.Rd @@ -16,7 +16,7 @@ tidy_stan(x, conf.int = FALSE, conf.level = 0.95, exponentiate = FALSE, ...) \item{conf.level}{The confidence level to use for the confidence interval if conf.int = TRUE. Must be strictly greater than 0 and less than 1. Defaults to 0.95, which corresponds to a 95 percent confidence interval.} -\item{exponentiate}{Logical indicating whether or not to exponentiate the the coefficient estimates. Defaults to FALSE. Note that standard errors are not included when \code{exponentiate = TRUE}.} +\item{exponentiate}{Logical indicating whether or not to exponentiate the the coefficient estimates. Defaults to FALSE.} \item{...}{Other arguments to broom.mixed::tidy} } @@ -28,7 +28,7 @@ data.frame of results \description{ Note no standard errors or other summary statistics are provided -Note no standard errors or other summary statistics are provided +This function is deprecated. Please use the 'tidy' function from the 'broom.mixed' package. } \details{ See https://book.declaredesign.org/choosing-an-answer-strategy.html#bayesian-formalizations diff --git a/rdss.Rproj b/rdss.Rproj index ef6fa31..4f34d3e 100644 --- a/rdss.Rproj +++ b/rdss.Rproj @@ -1,8 +1,9 @@ Version: 1.0 +ProjectId: 7cca6168-e54d-486c-99b7-b0664e7caddd RestoreWorkspace: No SaveWorkspace: No -AlwaysSaveHistory: Default +AlwaysSaveHistory: No EnableCodeIndexing: Yes UseSpacesForTab: Yes