From a46d4f234c1f11f20523612a2ee728aa271be285 Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 12 Dec 2023 11:33:16 -0500 Subject: [PATCH 1/4] Update gh actions --- .github/workflows/R-CMD-check.yaml | 91 ++++++---------------------- .github/workflows/pkgdown.yaml | 71 ++++++++++------------ .github/workflows/pr-commands.yaml | 66 +++++++++++++------- .github/workflows/test-coverage.yaml | 62 +++++++++---------- 4 files changed, 124 insertions(+), 166 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index efae164..a3ac618 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,18 +1,10 @@ -# NOTE: This workflow is overkill for most R packages -# check-standard.yaml is likely a better choice -# usethis::use_github_action("check-standard") will install it. -# -# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. -# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +# 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 + branches: [main, master] pull_request: - branches: - - main - - master + branches: [main, master] name: R-CMD-check @@ -26,77 +18,32 @@ jobs: fail-fast: false matrix: config: - - {os: macOS-latest, r: 'release'} + - {os: macos-latest, r: 'release'} - {os: windows-latest, r: 'release'} - - {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } - - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-18.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} env: - RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 - id: install-r + - 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-pandoc@v1 - - - name: Install pak and query dependencies - run: | - install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") - saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") - shell: Rscript {0} - - - name: Restore R package cache - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} - restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - pak::local_system_requirements(execute = TRUE) - pak::pkg_system_requirements("rcmdcheck", execute = TRUE) - shell: Rscript {0} - - - name: Install dependencies - run: | - pak::local_install_dev_deps(upgrade = TRUE) - pak::pkg_install("rcmdcheck") - shell: Rscript {0} - - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_: false - run: | - options(crayon.enabled = TRUE) - rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash + extra-packages: any::rcmdcheck + needs: check - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main + - uses: r-lib/actions/check-r-package@v2 with: - name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results - path: check + upload-snapshots: true diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 3eb8dd9..ed7650c 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,57 +1,48 @@ +# 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 + branches: [main, master] + pull_request: + branches: [main, master] + release: + types: [published] + workflow_dispatch: name: pkgdown jobs: pkgdown: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: - RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - + permissions: + contents: write steps: - - uses: actions/checkout@v2 - - - uses: r-lib/actions/setup-r@v1 - id: install-r + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Install pak and query dependencies - run: | - install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") - saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") - shell: Rscript {0} + - uses: r-lib/actions/setup-pandoc@v2 - - name: Restore R package cache - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} - restore-keys: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1- + use-public-rspm: true - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - pak::local_system_requirements(execute = TRUE) - pak::pkg_system_requirements("pkgdown", execute = TRUE) - shell: Rscript {0} + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website - - name: Install dependencies - run: | - pak::local_install_dev_deps(upgrade = TRUE) - pak::pkg_install("pkgdown") + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} - - name: Install package - run: R CMD INSTALL . - - - name: Build and deploy pkgdown site - run: | - git config --local user.name "$GITHUB_ACTOR" - git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" - Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.4.1 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index e5edf9f..71f335b 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -1,55 +1,79 @@ +# 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: issue_comment: types: [created] + name: Commands + jobs: document: - if: startsWith(github.event.comment.body, '/document') + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} name: document - runs-on: macOS-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 - - uses: r-lib/actions/pr-fetch@v1 + - uses: actions/checkout@v3 + + - uses: r-lib/actions/pr-fetch@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: r-lib/actions/setup-r@v1 - - name: Install dependencies - run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)' + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::roxygen2 + needs: pr-document + - name: Document - run: Rscript -e 'roxygen2::roxygenise()' + run: roxygen2::roxygenise() + shell: Rscript {0} + - name: commit run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" git add man/\* NAMESPACE git commit -m 'Document' - - uses: r-lib/actions/pr-push@v1 + + - uses: r-lib/actions/pr-push@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + style: - if: startsWith(github.event.comment.body, '/style') + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} name: style - runs-on: macOS-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 - - uses: r-lib/actions/pr-fetch@v1 + - uses: actions/checkout@v3 + + - uses: r-lib/actions/pr-fetch@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: r-lib/actions/setup-r@v1 + + - uses: r-lib/actions/setup-r@v2 + - name: Install dependencies - run: Rscript -e 'install.packages("styler")' + run: install.packages("styler") + shell: Rscript {0} + - name: Style - run: Rscript -e 'styler::style_pkg()' + run: styler::style_pkg() + shell: Rscript {0} + - name: commit run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" git add \*.R git commit -m 'Style' - - uses: r-lib/actions/pr-push@v1 + + - uses: r-lib/actions/pr-push@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 965cd84..27d4528 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -1,54 +1,50 @@ +# 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 + branches: [main, master] pull_request: - branches: - - main - - master + branches: [main, master] name: test-coverage jobs: test-coverage: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest env: - RSPM: https://packagemanager.rstudio.com/cran/__linux__/bionic/latest GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - - uses: r-lib/actions/setup-r@v1 - id: install-r - - - name: Install pak and query dependencies - run: | - install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") - saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") - shell: Rscript {0} + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true - - name: Restore R package cache - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} - restore-keys: ubuntu-18.04-${{ steps.install-r.outputs.installed-r-version }}-1- + extra-packages: any::covr + needs: coverage - - name: Install system dependencies - if: runner.os == 'Linux' + - name: Test coverage run: | - pak::local_system_requirements(execute = TRUE) - pak::pkg_system_requirements("covr", execute = TRUE) + covr::codecov( + quiet = FALSE, + clean = FALSE, + install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") + ) shell: Rscript {0} - - name: Install dependencies + - name: Show testthat output + if: always() run: | - pak::local_install_dev_deps(upgrade = TRUE) - pak::pkg_install("covr") - shell: Rscript {0} + ## -------------------------------------------------------------------- + find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash - - name: Test coverage - run: covr::codecov() - shell: Rscript {0} + - name: Upload test results + if: failure() + uses: actions/upload-artifact@v3 + with: + name: coverage-test-failures + path: ${{ runner.temp }}/package From b166452581a2e4c7fe58072597ac13c525c2d5c7 Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 12 Dec 2023 12:34:24 -0500 Subject: [PATCH 2/4] Remove tidyverse, forcats dep (and implicit readr) + remove unused dependencies. --- DESCRIPTION | 9 +-------- R/modeltime_fit_resamples.R | 2 +- R/plot_modeltime_resamples.R | 6 +++--- man/modeltime_fit_resamples.Rd | 2 +- tests/testthat.R | 1 - tests/testthat/test-modeltime_fit_resamples.R | 3 --- vignettes/getting-started.Rmd | 11 ++++++++++- vignettes/panel-data.Rmd | 17 +++++++++++++---- 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b001c96..6369336 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,30 +30,23 @@ Imports: dplyr, tidyr, purrr, - forcats, - glue, stringr, ggplot2, plotly, cli, - crayon, magrittr, rlang (>= 0.1.2), progressr, tictoc, hardhat Suggests: - roxygen2, testthat, tidymodels, - tidyverse, tidyquant, glmnet, lubridate, knitr, - rmarkdown, - covr, - remotes + rmarkdown Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 VignetteBuilder: knitr diff --git a/R/modeltime_fit_resamples.R b/R/modeltime_fit_resamples.R index 7a31332..8a25328 100644 --- a/R/modeltime_fit_resamples.R +++ b/R/modeltime_fit_resamples.R @@ -45,7 +45,7 @@ #' library(tidymodels) #' library(modeltime) #' library(timetk) -#' library(tidyverse) +#' library(magrittr) #' #' # Make resamples #' resamples_tscv <- training(m750_splits) %>% diff --git a/R/plot_modeltime_resamples.R b/R/plot_modeltime_resamples.R index ad88e26..359f5ba 100644 --- a/R/plot_modeltime_resamples.R +++ b/R/plot_modeltime_resamples.R @@ -110,17 +110,17 @@ plot_modeltime_resamples <- function(.data, # Prepare Data for Plot data_prepared <- resample_results_tbl %>% - dplyr::rename(.value = !! target_var) %>% + dplyr::rename(.value = !!target_var) %>% dplyr::mutate(.model_desc = ifelse(!is.na(.model_id), stringr::str_c(.model_id, "_", .model_desc), .model_desc)) %>% dplyr::mutate(.model_desc = .model_desc %>% stringr::str_trunc(width = .legend_max_width)) %>% - dplyr::mutate(.model_desc = forcats::as_factor(.model_desc)) %>% + dplyr::mutate(.model_desc = as.factor(.model_desc)) %>% dplyr::group_by(.resample_id, .model_desc) %>% .metric_set(.value, .pred) %>% dplyr::ungroup() %>% - dplyr::mutate(.metric = forcats::as_factor(.metric)) %>% + dplyr::mutate(.metric = as.factor(.metric)) %>% dplyr::group_by(.model_desc, .metric) %>% dplyr::mutate(..summary_fn = summary_fn_partial(.estimate)) %>% diff --git a/man/modeltime_fit_resamples.Rd b/man/modeltime_fit_resamples.Rd index b099134..3cba8fb 100644 --- a/man/modeltime_fit_resamples.Rd +++ b/man/modeltime_fit_resamples.Rd @@ -52,7 +52,7 @@ The sub-model cross-validation predictions are used as the input to the meta-lea library(tidymodels) library(modeltime) library(timetk) -library(tidyverse) +library(magrittr) # Make resamples resamples_tscv <- training(m750_splits) \%>\% diff --git a/tests/testthat.R b/tests/testthat.R index e272955..a74093b 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -8,7 +8,6 @@ library(modeltime.resample) library(glmnet) # Core Packages -library(tidyverse) library(timetk) library(lubridate) diff --git a/tests/testthat/test-modeltime_fit_resamples.R b/tests/testthat/test-modeltime_fit_resamples.R index 926f556..d7edb90 100644 --- a/tests/testthat/test-modeltime_fit_resamples.R +++ b/tests/testthat/test-modeltime_fit_resamples.R @@ -1,14 +1,11 @@ context("TEST: modeltime_fit_resamples()") -library(testthat) - # Machine Learning library(tidymodels) library(modeltime) library(modeltime.resample) # Core Packages -library(tidyverse) library(timetk) library(lubridate) diff --git a/vignettes/getting-started.Rmd b/vignettes/getting-started.Rmd index 3b88015..f154b44 100644 --- a/vignettes/getting-started.Rmd +++ b/vignettes/getting-started.Rmd @@ -37,7 +37,7 @@ In this tutorial, we'll get you up to speed by evaluating multiple models using Load the following R packages. -```{r} +```r library(tidymodels) library(modeltime) library(modeltime.resample) @@ -45,6 +45,15 @@ library(tidyverse) library(timetk) ``` +```{r, echo=FALSE,include=FALSE} +library(tidymodels) +library(modeltime) +library(modeltime.resample) +library(dplyr) +library(timetk) +``` + + We'll work with the `m750` data set. ```{r} diff --git a/vignettes/panel-data.Rmd b/vignettes/panel-data.Rmd index a2985d8..268d198 100644 --- a/vignettes/panel-data.Rmd +++ b/vignettes/panel-data.Rmd @@ -34,7 +34,7 @@ __This is an advanced tutorial.__ Working with Panel Data requires working with Load the following R packages. -```{r setup} +```r library(tidymodels) library(modeltime) library(modeltime.resample) @@ -43,6 +43,15 @@ library(tidyverse) library(tidyquant) ``` +```{r setup,echo=FALSE,include=FALSE} +library(tidymodels) +library(modeltime) +library(modeltime.resample) +library(timetk) +library(dplyr) +library(tidyquant) +``` + ## Data We'll use the `walmart_sales_weekly` dataset from `timetk`. This contains 7 time series groups, which correspond to the revenue over time for seven departments in one Walmart Store. @@ -76,7 +85,7 @@ full_data_tbl <- walmart_sales_weekly %>% ungroup() %>% # Consolidate IDs - mutate(id = fct_drop(id)) + mutate(id = droplevels(id)) # Training Data data_prepared_tbl <- full_data_tbl %>% @@ -250,8 +259,8 @@ resample_results <- model_tbl %>% ``` ```{r, echo=FALSE} -# write_rds(resample_results, "resample_results.rds") -resample_results <- read_rds("resample_results.rds") +# saveRDS(resample_results, "resample_results.rds") +resample_results <- readRDS("resample_results.rds") ``` A new column (".resample_results") containing the resample predictions has been added to the original `model_tbl`. From 20158e84f03f0939c93e9a870910fd15c62656a7 Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 12 Dec 2023 12:48:16 -0500 Subject: [PATCH 3/4] Use ggplot2 linewidth and dplyr::everything with `across()`. --- R/modeltime_fit_resamples.R | 2 ++ R/modeltime_resample_accuracy.R | 5 ++--- R/plot_modeltime_resamples.R | 12 ++++++------ R/tidyquant-theme-compat.R | 24 ++++++++++++------------ man/plot_modeltime_resamples.Rd | 4 ++-- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/R/modeltime_fit_resamples.R b/R/modeltime_fit_resamples.R index 8a25328..32d56fd 100644 --- a/R/modeltime_fit_resamples.R +++ b/R/modeltime_fit_resamples.R @@ -93,6 +93,8 @@ modeltime_fit_resamples.mdl_time_tbl <- function(object, resamples, control = co if (!control$save_pred) control$save_pred <- TRUE + # TODO Consider removing tictoc and progressr dep in favor + # of cli::cli_progress_step() if (control$verbose) { tictoc::tic() print(cli::rule("Fitting Resamples", width = 65)) diff --git a/R/modeltime_resample_accuracy.R b/R/modeltime_resample_accuracy.R index 118049c..ef39d6f 100644 --- a/R/modeltime_resample_accuracy.R +++ b/R/modeltime_resample_accuracy.R @@ -99,10 +99,9 @@ modeltime_resample_accuracy <- function(object, summary_fns = mean, metric_set = dplyr::mutate(n = dplyr::n()) %>% dplyr::group_by(.model_id, .model_desc, .type, n) %>% dplyr::summarise( - dplyr::across(.fns = summary_fns, ...), + dplyr::across(.cols = dplyr::everything(), .fns = summary_fns, ...), .groups = "drop" - ) %>% - dplyr::ungroup() + ) } diff --git a/R/plot_modeltime_resamples.R b/R/plot_modeltime_resamples.R index 359f5ba..5164436 100644 --- a/R/plot_modeltime_resamples.R +++ b/R/plot_modeltime_resamples.R @@ -22,12 +22,12 @@ #' @param .point_shape Controls the point shape. Default: 16. #' @param .point_alpha Controls the opacity of the points. Default: 1 (full opacity). #' @param .summary_line_show Whether or not to show the summary lines. Default: `TRUE`. -#' @param .summary_line_size Controls the summary line size. Default: 0.5. +#' @param .summary_line_size Controls the summary line width. Default: 0.5. #' @param .summary_line_type Controls the summary line type. Default: 1. #' @param .summary_line_alpha Controls the summary line opacity. Default: 1 (full opacity). #' @param .x_intercept Numeric. Adds an x-intercept at a location (e.g. 0). Default: NULL. #' @param .x_intercept_color Controls the x-intercept color. Default: "red". -#' @param .x_intercept_size Controls the x-intercept size. Default: 0.5. +#' @param .x_intercept_size Controls the x-intercept linewidth. Default: 0.5. #' #' @details #' @@ -147,9 +147,9 @@ plot_modeltime_resamples <- function(.data, if (.summary_line_show) { g <- g + ggplot2::geom_vline(ggplot2::aes(xintercept = ..summary_fn, color = .model_desc), - size = .summary_line_size, - alpha = .summary_line_alpha, - linetype = .summary_line_type) + linewidth = .summary_line_size, + alpha = .summary_line_alpha, + linetype = .summary_line_type) } # Add a X-Intercept if desired @@ -157,7 +157,7 @@ plot_modeltime_resamples <- function(.data, g <- g + ggplot2::geom_vline(xintercept = .x_intercept, color = .x_intercept_color, - size = .x_intercept_size) + linewidth = .x_intercept_size) } # Add theme & labs diff --git a/R/tidyquant-theme-compat.R b/R/tidyquant-theme-compat.R index 2fb917f..a1973a6 100644 --- a/R/tidyquant-theme-compat.R +++ b/R/tidyquant-theme-compat.R @@ -15,10 +15,10 @@ theme_tq <- function(base_size = 11, base_family = "") { ggplot2::theme( # Base Inherited Elements - line = ggplot2::element_line(colour = blue, size = 0.5, linetype = 1, + line = ggplot2::element_line(colour = blue, linewidth = 0.5, linetype = 1, lineend = "butt"), rect = ggplot2::element_rect(fill = white, colour = blue, - size = 0.5, linetype = 1), + linewidth = 0.5, linetype = 1), text = ggplot2::element_text(family = base_family, face = "plain", colour = blue, size = base_size, lineheight = 0.9, hjust = 0.5, vjust = 0.5, angle = 0, @@ -27,14 +27,14 @@ theme_tq <- function(base_size = 11, base_family = "") { # Axes axis.line = ggplot2::element_blank(), axis.text = ggplot2::element_text(size = ggplot2::rel(0.8)), - axis.ticks = ggplot2::element_line(color = grey, size = ggplot2::rel(1/3)), + axis.ticks = ggplot2::element_line(color = grey, linewidth = ggplot2::rel(1/3)), axis.title = ggplot2::element_text(size = ggplot2::rel(1.0)), # Panel panel.background = ggplot2::element_rect(fill = white, color = NA), - panel.border = ggplot2::element_rect(fill = NA, size = ggplot2::rel(1/2), color = blue), - panel.grid.major = ggplot2::element_line(color = grey, size = ggplot2::rel(1/3)), - panel.grid.minor = ggplot2::element_line(color = grey, size = ggplot2::rel(1/3)), + panel.border = ggplot2::element_rect(fill = NA, linewidth = ggplot2::rel(1/2), color = blue), + panel.grid.major = ggplot2::element_line(color = grey, linewidth = ggplot2::rel(1/3)), + panel.grid.minor = ggplot2::element_line(color = grey, linewidth = ggplot2::rel(1/3)), panel.grid.minor.x = ggplot2::element_blank(), panel.spacing = ggplot2::unit(.75, "cm"), @@ -70,12 +70,12 @@ theme_tq_dark <- function(base_size = 11, base_family = "") { ggplot2::theme( # Axes - axis.ticks = ggplot2::element_line(color = blue, size = ggplot2::rel(1/3)), + axis.ticks = ggplot2::element_line(color = blue, linewidth = ggplot2::rel(1/3)), # Panel panel.background = ggplot2::element_rect(fill = grey, color = NA), - panel.grid.major = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)), - panel.grid.minor = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)), + panel.grid.major = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)), + panel.grid.minor = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)), # Complete theme complete = TRUE @@ -95,12 +95,12 @@ theme_tq_green <- function(base_size = 11, base_family = "") { ggplot2::theme( # Axes - axis.ticks = ggplot2::element_line(color = blue, size = ggplot2::rel(1/3)), + axis.ticks = ggplot2::element_line(color = blue, linewidth = ggplot2::rel(1/3)), # Panel panel.background = ggplot2::element_rect(fill = green, color = NA), - panel.grid.major = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)), - panel.grid.minor = ggplot2::element_line(color = white, size = ggplot2::rel(1/3)), + panel.grid.major = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)), + panel.grid.minor = ggplot2::element_line(color = white, linewidth = ggplot2::rel(1/3)), # Complete theme complete = TRUE diff --git a/man/plot_modeltime_resamples.Rd b/man/plot_modeltime_resamples.Rd index 0f500eb..372de68 100644 --- a/man/plot_modeltime_resamples.Rd +++ b/man/plot_modeltime_resamples.Rd @@ -58,7 +58,7 @@ of models and metrics. Default: \code{TRUE}.} \item{.summary_line_show}{Whether or not to show the summary lines. Default: \code{TRUE}.} -\item{.summary_line_size}{Controls the summary line size. Default: 0.5.} +\item{.summary_line_size}{Controls the summary line width. Default: 0.5.} \item{.summary_line_type}{Controls the summary line type. Default: 1.} @@ -68,7 +68,7 @@ of models and metrics. Default: \code{TRUE}.} \item{.x_intercept_color}{Controls the x-intercept color. Default: "red".} -\item{.x_intercept_size}{Controls the x-intercept size. Default: 0.5.} +\item{.x_intercept_size}{Controls the x-intercept linewidth. Default: 0.5.} \item{.legend_show}{Logical. Whether or not to show the legend. Can save space with long model descriptions.} From c808474742eacde6764451413d15ce5455730adc Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 12 Dec 2023 12:49:12 -0500 Subject: [PATCH 4/4] devtools::build_readme() + update News --- DESCRIPTION | 8 +++--- NEWS.md | 8 +++++- README.Rmd | 2 +- README.md | 75 ++++++++++++++++++++++++++++++++++------------------- 4 files changed, 60 insertions(+), 33 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6369336..a979a3e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: modeltime.resample Title: Resampling Tools for Time Series Forecasting -Version: 0.2.3 +Version: 0.2.3.9000 Authors@R: c( person("Matt", "Dancho", email = "mdancho@business-science.io", role = c("aut", "cre")), person("Business Science", role = "cph") @@ -12,7 +12,7 @@ Description: License: MIT + file LICENSE Encoding: UTF-8 LazyData: true -URL: https://github.com/business-science/modeltime.resample +URL: https://business-science.github.io/modeltime.resample/, https://github.com/business-science/modeltime.resample BugReports: https://github.com/business-science/modeltime.resample/issues Depends: modeltime (>= 0.3.0), @@ -27,11 +27,11 @@ Imports: yardstick, timetk (>= 2.5.0), tibble, - dplyr, + dplyr (>= 1.0.0), tidyr, purrr, stringr, - ggplot2, + ggplot2 (>= 3.4.0), plotly, cli, magrittr, diff --git a/NEWS.md b/NEWS.md index 32e42d7..0c9a696 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,10 @@ -# modeltime.resample 0.2.2.9000 (Development Version) +# modeltime.resample (development version) + +- Update for better compatibility with dplyr 1.1.0 and ggplot2 3.4.4 (@olivroy, #16) + +- Remove dependency on tidyverse (@olivroy, #16) + +# modeltime.resample 0.2.3 - Resubmit to CRAN (timetk issue) diff --git a/README.Rmd b/README.Rmd index a153c97..15365f0 100644 --- a/README.Rmd +++ b/README.Rmd @@ -26,7 +26,7 @@ library(modeltime.resample) [![CRAN status](https://www.r-pkg.org/badges/version/modeltime.resample)](https://CRAN.R-project.org/package=modeltime.resample) ![](http://cranlogs.r-pkg.org/badges/modeltime.resample?color=brightgreen) ![](http://cranlogs.r-pkg.org/badges/grand-total/modeltime.resample?color=brightgreen) -[![R-CMD-check](https://github.com/business-science/modeltime.resample/workflows/R-CMD-check/badge.svg)](https://github.com/business-science/modeltime.resample/actions) +[![R-CMD-check](https://github.com/business-science/modeltime.resample/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/business-science/modeltime.resample/actions/workflows/R-CMD-check.yaml) [![Codecov test coverage](https://codecov.io/gh/business-science/modeltime.resample/branch/master/graph/badge.svg)](https://app.codecov.io/gh/business-science/modeltime.resample?branch=master) diff --git a/README.md b/README.md index 3a788aa..99adc25 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ status](https://www.r-pkg.org/badges/version/modeltime.resample)](https://CRAN.R-project.org/package=modeltime.resample) ![](http://cranlogs.r-pkg.org/badges/modeltime.resample?color=brightgreen) ![](http://cranlogs.r-pkg.org/badges/grand-total/modeltime.resample?color=brightgreen) -[![R-CMD-check](https://github.com/business-science/modeltime.resample/workflows/R-CMD-check/badge.svg)](https://github.com/business-science/modeltime.resample/actions) +[![R-CMD-check](https://github.com/business-science/modeltime.resample/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/business-science/modeltime.resample/actions/workflows/R-CMD-check.yaml) [![Codecov test coverage](https://codecov.io/gh/business-science/modeltime.resample/branch/master/graph/badge.svg)](https://app.codecov.io/gh/business-science/modeltime.resample?branch=master) @@ -58,9 +58,23 @@ where we can see that Prophet Boost and XGBoost Models outperform Prophet with Regressors for the Walmart Time Series Panel Dataset using the 6-Slice Time Series Cross Validation plan shown above. -Model Accuracy for 6 Time Series Resamples +
-Resampled Model Accuracy (3 Models, 6 Resamples, 7 Time Series Groups) +Model Accuracy for 6 Time Series Resamples +

+Model Accuracy for 6 Time Series Resamples +

+ +
+ +
+ +Resampled Model Accuracy (3 Models, 6 Resamples, 7 Time Series Groups) +

+Resampled Model Accuracy (3 Models, 6 Resamples, 7 Time Series Groups) +

+ +
## Getting Started @@ -79,28 +93,35 @@ the 6-Slice Time Series Cross Validation plan shown above. > Learn a growing ecosystem of forecasting packages -The modeltime ecosystem is growing +
+ +The modeltime ecosystem is growing +

+The modeltime ecosystem is growing +

+ +
Modeltime is part of a **growing ecosystem** of Modeltime forecasting packages. -- [Modeltime (Machine - Learning)](https://business-science.github.io/modeltime/) +- [Modeltime (Machine + Learning)](https://business-science.github.io/modeltime/) -- [Modeltime H2O - (AutoML)](https://business-science.github.io/modeltime.h2o/) +- [Modeltime H2O + (AutoML)](https://business-science.github.io/modeltime.h2o/) -- [Modeltime GluonTS (Deep - Learning)](https://business-science.github.io/modeltime.gluonts/) +- [Modeltime GluonTS (Deep + Learning)](https://business-science.github.io/modeltime.gluonts/) -- [Modeltime Ensemble (Blending - Forecasts)](https://business-science.github.io/modeltime.ensemble/) +- [Modeltime Ensemble (Blending + Forecasts)](https://business-science.github.io/modeltime.ensemble/) -- [Modeltime Resample - (Backtesting)](https://business-science.github.io/modeltime.resample/) +- [Modeltime Resample + (Backtesting)](https://business-science.github.io/modeltime.resample/) -- [Timetk (Feature Engineering, Data Wrangling, Time Series - Visualization)](https://business-science.github.io/timetk/) +- [Timetk (Feature Engineering, Data Wrangling, Time Series + Visualization)](https://business-science.github.io/timetk/) ## Take the High-Performance Forecasting Course @@ -130,17 +151,17 @@ Series Forecasting Course**](https://university.business-science.io/p/ds4b-203-r-high-performance-time-series-forecasting). You will learn: -- **Time Series Machine Learning** (cutting-edge) with `Modeltime` - - 30+ Models (Prophet, ARIMA, XGBoost, Random Forest, & many more) -- **Deep Learning** with `GluonTS` (Competition Winners) -- **Time Series Preprocessing**, Noise Reduction, & Anomaly Detection -- **Feature engineering** using lagged variables & external regressors -- **Hyperparameter Tuning** -- **Time series cross-validation** -- **Ensembling** Multiple Machine Learning & Univariate Modeling - Techniques (Competition Winner) -- **Scalable Forecasting** - Forecast 1000+ time series in parallel -- and more. +- **Time Series Machine Learning** (cutting-edge) with `Modeltime` - 30+ + Models (Prophet, ARIMA, XGBoost, Random Forest, & many more) +- **Deep Learning** with `GluonTS` (Competition Winners) +- **Time Series Preprocessing**, Noise Reduction, & Anomaly Detection +- **Feature engineering** using lagged variables & external regressors +- **Hyperparameter Tuning** +- **Time series cross-validation** +- **Ensembling** Multiple Machine Learning & Univariate Modeling + Techniques (Competition Winner) +- **Scalable Forecasting** - Forecast 1000+ time series in parallel +- and more.

Become the Time Series Expert for your organization.