From 3d907de485dd873397b5de7219909f40a4247557 Mon Sep 17 00:00:00 2001 From: Earo Wang Date: Wed, 24 Jan 2024 13:46:09 +1100 Subject: [PATCH] fixed `count_gaps()` warning due to dplyr change closes #295 --- DESCRIPTION | 2 +- NAMESPACE | 1 + NEWS.md | 1 + R/gaps.R | 4 ++-- R/tsibble-package.R | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 975842c7..b74cf5e4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,7 +38,7 @@ Depends: R (>= 3.2.0) Imports: anytime (>= 0.3.1), - dplyr (>= 1.0.0), + dplyr (>= 1.1.0), ellipsis (>= 0.3.0), generics, lifecycle, diff --git a/NAMESPACE b/NAMESPACE index 26993dc1..d6df2aee 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -361,6 +361,7 @@ importFrom(dplyr,left_join) importFrom(dplyr,mutate) importFrom(dplyr,new_grouped_df) importFrom(dplyr,pull) +importFrom(dplyr,reframe) importFrom(dplyr,rename) importFrom(dplyr,right_join) importFrom(dplyr,select) diff --git a/NEWS.md b/NEWS.md index bc788d48..c0d20c14 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # tsibble 1.1.4 * Fixed `vec_ptype2()` for `yearweek` and `yearquarter` for non-default week start. (#299) +* Fixed `count_gaps()` warning message due to dplyr deprecation in favour of `reframe()`. (#295) # tsibble 1.1.3 diff --git a/R/gaps.R b/R/gaps.R index ef82a37a..220e2b9f 100644 --- a/R/gaps.R +++ b/R/gaps.R @@ -232,7 +232,7 @@ count_gaps <- function(.data, .full = FALSE, .name = c(".from", ".to", ".n"), idx_full <- seq_generator(.data[[as_string(idx)]], int) grped_tbl <- new_grouped_df(gap_data, groups = key_data(gap_data)) - lst_out <- summarise(grped_tbl, + lst_out <- reframe(grped_tbl, !!".gaps" := tbl_gaps(!!idx, idx_full, .name = .name)) vec_cbind(lst_out[key_vars(.data)], vec_cbind(!!!lst_out$.gaps)) @@ -342,7 +342,7 @@ seq_generator <- function(x, time_units = NULL, length_out = NULL) { if (time_units == 0) return(x) min_x <- min(x) - seq_call <- quote(seq(from = min_x, to = max(x), by = time_units, + seq_call <- quote(seq(from = min_x, to = max(x), by = time_units, length.out = length_out)) if (!is.null(length_out)) { seq_call <- call_modify(seq_call, to = zap()) diff --git a/R/tsibble-package.R b/R/tsibble-package.R index 02707bc4..b57087f6 100644 --- a/R/tsibble-package.R +++ b/R/tsibble-package.R @@ -85,7 +85,7 @@ #' @importFrom dplyr group_by ungroup group_data grouped_df group_vars #' @importFrom dplyr group_rows groups new_grouped_df is_grouped_df #' @importFrom dplyr left_join right_join full_join inner_join anti_join -#' @importFrom dplyr bind_rows bind_cols combine with_order pull first +#' @importFrom dplyr bind_rows bind_cols combine with_order pull first reframe #' @importFrom dplyr dplyr_row_slice dplyr_col_modify dplyr_reconstruct #' @importFrom tibble new_tibble trunc_mat #' @import rlang tidyselect vctrs ellipsis