From 46f04e74833e8f7e2dbc390fc57974d1c4b7c304 Mon Sep 17 00:00:00 2001 From: mpadge Date: Fri, 26 Jun 2020 11:36:31 +0200 Subject: [PATCH] issue message on base::plot to use feasts instead --- NAMESPACE | 1 + R/utils.R | 7 +++++++ tests/testthat/test-print.R | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 9e25df56..bf4cc159 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -96,6 +96,7 @@ S3method(new_data,tbl_ts) S3method(obj_print_data,yearmonth) S3method(obj_print_data,yearquarter) S3method(obj_print_data,yearweek) +S3method(plot,tbl_ts) S3method(scan_gaps,tbl_ts) S3method(select,grouped_ts) S3method(select,tbl_ts) diff --git a/R/utils.R b/R/utils.R index a7a130f1..2dddb7a9 100644 --- a/R/utils.R +++ b/R/utils.R @@ -78,3 +78,10 @@ format_tz <- function(x) { tz } } + +#' @export +plot.tbl_ts <- function(x, ...) { + message ("The 'autoplot' function from the 'feasts' package is ", + "recommended for plotting 'tsibble' objects") + plot.default(x, ...) +} diff --git a/tests/testthat/test-print.R b/tests/testthat/test-print.R index ae1f26d1..de413782 100644 --- a/tests/testthat/test-print.R +++ b/tests/testthat/test-print.R @@ -48,3 +48,11 @@ test_that("tbl_sum.grouped_ts()", { ) ) }) + +test_that("plot message issued", { + expect_message( + plot(pedestrian), + paste0 ("The 'autoplot' function from the 'feasts' package is ", + "recommended for plotting 'tsibble' objects") + ) +})