Skip to content

Commit

Permalink
Merge pull request #155 from olivroy/upkeep2
Browse files Browse the repository at this point in the history
  • Loading branch information
mdancho84 authored Oct 3, 2023
2 parents dafa4c0 + 300cf88 commit 182e485
Show file tree
Hide file tree
Showing 472 changed files with 331 additions and 91,115 deletions.
Binary file removed .DS_Store
Binary file not shown.
1 change: 0 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
^data-raw$
^README\.Rmd$
^README-.*\.png$
^\.travis\.yml$
^cran-comments\.md$
^revdep$
img
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Meta
docs
/doc/
/Meta/
docs/
8 changes: 3 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: timetk
Type: Package
Title: A Tool Kit for Working with Time Series
Version: 2.8.4
Version: 2.8.4.9000
Authors@R: c(
person("Matt", "Dancho", email = "[email protected]", role = c("aut", "cre")),
person("Davis", "Vaughan", email = "[email protected]", role = c("aut"))
Expand Down Expand Up @@ -43,15 +43,13 @@ Imports:
forecast,
tsfeatures,
hms,
generics,
tidymodels
generics
Suggests:
modeltime,
glmnet,
workflows,
parsnip,
tune,
yardstick,
tune (>= 0.1.2),
knitr,
rmarkdown,
broom,
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# timetk (development version)

- Removed dependency on tidymodels. (#154, @olivroy).


# timetk 2.8.4

Update forecasting vignette: Use `glmnet` for time series forecasting.
Expand Down
1 change: 0 additions & 1 deletion R/augment-tk_augment_differences.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#' m4_monthly %>%
#' group_by(id) %>%
Expand Down
3 changes: 1 addition & 2 deletions R/augment-tk_augment_fourier.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#' m4_monthly %>%
#' group_by(id) %>%
Expand All @@ -65,7 +64,7 @@ tk_augment_fourier <- function(.data,
# if (rlang::is_missing(.K)) stop(call. = FALSE, "tk_augment_fourier(.K) is missing.")
if (!any(.names == "auto")) {
if (length(.names) != length(.periods) * 2) {
rlang::abort(".names must be a vector of length ", length(.periods) * 2)
rlang::abort(c(".names must be a vector of length ", length(.periods) * 2))
}
}
vals <- .data %>% dplyr::pull(!! rlang::enquo(.date_var))
Expand Down
8 changes: 3 additions & 5 deletions R/augment-tk_augment_holiday_signature.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#' dates_in_2017_tbl <- tibble(index = tk_make_timeseries("2017-01-01", "2017-12-31", by = "day"))
#'
Expand Down Expand Up @@ -137,11 +136,10 @@ tk_augment_holiday_signature.data.frame <- function(.data,
# .data <- .data %>% dplyr::arrange(!! sym(date_var))

# Bind Time Series Signature
ret_1 <- .data %>% dplyr::ungroup()
ret_1 <- dplyr::ungroup(.data)

ret_2 <- .data %>%
dplyr::ungroup() %>%
dplyr::pull(date_var) %>%
ret_2 <- ret_1 %>%
dplyr::pull(dplyr::all_of(date_var)) %>%
tk_get_holiday_signature(
holiday_pattern = .holiday_pattern,
locale_set = .locale_set,
Expand Down
1 change: 0 additions & 1 deletion R/augment-tk_augment_lags.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#' # Lags
#' m4_monthly %>%
Expand Down
6 changes: 2 additions & 4 deletions R/augment-tk_augment_slidify.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
#'
#' @examples
#' library(dplyr)
#' library(stringr)
#' library(timetk)
#'
#' # Single Column | Multiple Rolling Windows
#' FANG %>%
Expand All @@ -55,7 +53,7 @@
#' .period = c(10, 30, 60, 90),
#' .f = mean,
#' .partial = TRUE,
#' .names = str_c("MA_", c(10, 30, 60, 90))
#' .names = stringr::str_c("MA_", c(10, 30, 60, 90))
#' ) %>%
#' ungroup()
#'
Expand Down Expand Up @@ -184,7 +182,7 @@ tk_augment_slidify.grouped_df <- function(.data,
.names = .names
)
)) %>%
dplyr::select(-data) %>%
dplyr::select(-"data") %>%
tidyr::unnest(cols = nested.col) %>%
dplyr::group_by_at(.vars = group_names)
}
Expand Down
5 changes: 2 additions & 3 deletions R/augment-tk_augment_timeseries.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#' m4_daily %>%
#' group_by(id) %>%
Expand Down Expand Up @@ -109,7 +108,7 @@ tk_augment_timeseries_signature.grouped_df <- function(.data, .date_var = NULL)
.date_var = NULL
)
)) %>%
dplyr::select(-data) %>%
dplyr::select(-"data") %>%
tidyr::unnest(cols = nested.col) %>%
dplyr::group_by_at(.vars = group_names)
} else {
Expand All @@ -122,7 +121,7 @@ tk_augment_timeseries_signature.grouped_df <- function(.data, .date_var = NULL)
.date_var = !! date_var_expr
)
)) %>%
dplyr::select(-data) %>%
dplyr::select(-"data") %>%
tidyr::unnest(cols = nested.col) %>%
dplyr::group_by_at(.vars = group_names)
}
Expand Down
3 changes: 0 additions & 3 deletions R/coersion-tk_tbl.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
#' @seealso [tk_xts()], [tk_zoo()], [tk_zooreg()], [tk_ts()]
#'
#' @examples
#' library(tibble)
#' library(dplyr)
#' library(timetk)
#'
#' data_tbl <- tibble(
#' date = seq.Date(from = as.Date("2010-01-01"), by = 1, length.out = 5),
Expand Down Expand Up @@ -85,7 +83,6 @@
#'
#'
#'
#'
#' @export
tk_tbl <- function(data, preserve_index = TRUE, rename_index = "index", timetk_idx = FALSE, silent = FALSE, ...) {
UseMethod("tk_tbl", data)
Expand Down
2 changes: 0 additions & 2 deletions R/coersion-tk_ts.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
#' @seealso [tk_index()], [tk_tbl()], [tk_xts()], [tk_zoo()], [tk_zooreg()]
#'
#' @examples
#' library(tibble)
#' library(dplyr)
#' library(timetk)
#'
#' ### tibble to ts: Comparison between tk_ts() and stats::ts()
#' data_tbl <- tibble::tibble(
Expand Down
3 changes: 0 additions & 3 deletions R/coersion-tk_xts.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@
#' @seealso [tk_tbl()], [tk_zoo()], [tk_zooreg()], [tk_ts()]
#'
#' @examples
#' library(tibble)
#' library(dplyr)
#' library(timetk)
#'
#' ### tibble to xts: Comparison between tk_xts() and xts::xts()
#' data_tbl <- tibble::tibble(
Expand Down Expand Up @@ -69,7 +67,6 @@
#' select <- "y"
#' tk_xts_(data_tbl, select = select, date_var = date_var)
#'
#' @name tk_xts
#' @export
tk_xts <- function(data, select = NULL, date_var = NULL, silent = FALSE, ...) {
select <- rlang::quo_name(rlang::enquo(select))
Expand Down
4 changes: 1 addition & 3 deletions R/coersion-tk_zoo.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,10 @@
#' @seealso [tk_tbl()], [tk_xts()], [tk_zooreg()], [tk_ts()]
#'
#' @examples
#' library(tibble)
#' library(dplyr)
#' library(timetk)
#'
#' ### tibble to zoo: Comparison between tk_zoo() and zoo::zoo()
#' data_tbl <- tibble::tibble(
#' data_tbl <- dplyr::tibble(
#' date = seq.Date(as.Date("2016-01-01"), by = 1, length.out = 5),
#' x = rep("chr values", 5),
#' y = cumsum(1:5),
Expand Down
5 changes: 2 additions & 3 deletions R/diagnostics-tk_acf_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#' # ACF, PACF, & CCF in 1 Data Frame
#' # - Get ACF & PACF for target (adjusted)
Expand Down Expand Up @@ -139,7 +138,7 @@ tk_acf_diagnostics.data.frame <- function(.data, .date_var, .value, .ccf_vars =

# Calcs
.lags <- sort(.lags)
x <- .data %>% dplyr::pull(.value_mod)
x <- .data %>% dplyr::pull(".value_mod")
lag_max <- max(.lags)
lag_min <- min(.lags)

Expand Down Expand Up @@ -239,7 +238,7 @@ tk_acf_diagnostics.grouped_df <- function(.data, .date_var, .value, .ccf_vars =
.lags = .lags
)
)) %>%
dplyr::select(-data) %>%
dplyr::select(-"data") %>%
tidyr::unnest(cols = nested.col) %>%
dplyr::group_by_at(.vars = group_names)

Expand Down
13 changes: 6 additions & 7 deletions R/diagnostics-tk_anomaly_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#' walmart_sales_weekly %>%
#' filter(id %in% c("1_1", "1_3")) %>%
Expand Down Expand Up @@ -178,7 +177,7 @@ tk_anomaly_diagnostics.grouped_df <- function(.data, .date_var, .value,
.message = .message
)
)) %>%
dplyr::select(-data) %>%
dplyr::select(-"data") %>%
tidyr::unnest(cols = nested.col) %>%
dplyr::group_by_at(.vars = group_names)

Expand Down Expand Up @@ -294,15 +293,15 @@ iqr_vec <- function(x, alpha = 0.05, max_anoms = 0.2, verbose = FALSE) {
# Return results
if (verbose) {
outlier_list <- list(
outlier = vals_tbl %>% dplyr::arrange(index) %>% dplyr::pull(outlier_reported),
outlier_idx = vals_tbl %>% dplyr::filter(outlier_reported == "Yes") %>% dplyr::pull(index),
outlier_vals = vals_tbl %>% dplyr::filter(outlier_reported == "Yes") %>% dplyr::pull(value),
outlier_direction = vals_tbl %>% dplyr::filter(outlier_reported == "Yes") %>% dplyr::pull(direction),
outlier = vals_tbl %>% dplyr::arrange(index) %>% dplyr::pull("outlier_reported"),
outlier_idx = vals_tbl %>% dplyr::filter(outlier_reported == "Yes") %>% dplyr::pull("index"),
outlier_vals = vals_tbl %>% dplyr::filter(outlier_reported == "Yes") %>% dplyr::pull("value"),
outlier_direction = vals_tbl %>% dplyr::filter(outlier_reported == "Yes") %>% dplyr::pull("direction"),
critical_limits = limits_vec,
outlier_report = vals_tbl_filtered
)
return(outlier_list)
} else {
return(vals_tbl %>% dplyr::arrange(index) %>% dplyr::pull(outlier_reported))
return(vals_tbl %>% dplyr::arrange(index) %>% dplyr::pull("outlier_reported"))
}
}
7 changes: 3 additions & 4 deletions R/diagnostics-tk_seasonal_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#' @examples
#' \donttest{
#' library(dplyr)
#' library(timetk)
#'
#' # ---- GROUPED EXAMPLES ----
#'
Expand Down Expand Up @@ -170,7 +169,7 @@ tk_seasonal_diagnostics.grouped_df <- function(.data, .date_var, .value, .featur
.feature_set = .feature_set
)
)) %>%
dplyr::select(-data) %>%
dplyr::select(-"data") %>%
tidyr::unnest(cols = nested.col) %>%
dplyr::group_by_at(.vars = group_names)

Expand All @@ -194,7 +193,7 @@ get_seasonal_auto_features <- function(.index) {
dplyr::mutate(check = value %>% dplyr::between(max_min_list$min_period$value, max_min_list$max_period$value)) %>%
dplyr::filter(check) %>%
dplyr::left_join(time_series_signature_lookup_tbl(), by = "key") %>%
dplyr::pull(feature)
dplyr::pull("feature")

return(features_to_get)
}
Expand All @@ -219,7 +218,7 @@ get_max_min_list <- function(time_series_summary_tbl) {
tidyr::gather() %>%
dplyr::mutate(check = 2 * value < start_to_end) %>%
dplyr::filter(check) %>%
dplyr::slice(dplyr::n())
dplyr::slice_tail(n = 1)

# Max and min
max_min_list <- list(min_period = min_period, max_period = max_period)
Expand Down
3 changes: 1 addition & 2 deletions R/diagnostics-tk_stl_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#'
#' # ---- GROUPS & TRANSFORMATION ----
Expand Down Expand Up @@ -112,7 +111,7 @@ tk_stl_diagnostics.data.frame <- function(.data, .date_var, .value,

# STL Calculation
stl_obj <- data_formatted %>%
dplyr::pull(.value_mod) %>%
dplyr::pull(".value_mod") %>%
stats::ts(frequency = freq) %>%
stats::stl(s.window = "periodic", t.window = trnd, robust = TRUE)

Expand Down
1 change: 0 additions & 1 deletion R/diagnostics-tk_summary_diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#' # ---- NON-GROUPED EXAMPLES ----
#'
Expand Down
1 change: 0 additions & 1 deletion R/diagnostiscs-tsfeatures.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#' walmart_sales_weekly %>%
#' group_by(id) %>%
Expand Down
3 changes: 1 addition & 2 deletions R/dplyr-add_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#'
#'
#' @examples
#' library(timetk)
#'
#'
#' # ---- LOCATING A DATE N-PERIODS IN FUTURE / PAST ----
Expand Down Expand Up @@ -67,7 +66,7 @@
#'
#'
#' @name time_arithmetic
#' @export
NULL

# ADD ----

Expand Down
1 change: 0 additions & 1 deletion R/dplyr-between_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#' index_daily <- tk_make_timeseries("2016-01-01", "2017-01-01", by = "day")
#' index_min <- tk_make_timeseries("2016-01-01", "2017-01-01", by = "min")
Expand Down
1 change: 0 additions & 1 deletion R/dplyr-condense_period.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
#'
#' @examples
#' # Libraries
#' library(timetk)
#' library(dplyr)
#'
#' # First value in each month
Expand Down
1 change: 0 additions & 1 deletion R/dplyr-filter_by_time.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
#'
#' @examples
#' library(dplyr)
#' library(timetk)
#'
#' # Filter values in January 1st through end of February, 2013
#' FANG %>%
Expand Down
1 change: 0 additions & 1 deletion R/dplyr-filter_period.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
#'
#' @examples
#' # Libraries
#' library(timetk)
#' library(dplyr)
#'
#' # Max value in each month
Expand Down
Loading

0 comments on commit 182e485

Please sign in to comment.