From 6e3506738d49856398012705cfd0984e3cc1f568 Mon Sep 17 00:00:00 2001 From: Hong Ooi Date: Sat, 20 Jun 2020 06:27:50 +1000 Subject: [PATCH] Tidyverts update (#202) Updates the R code in the examples for the latest tidyverts package versions on CRAN. Former-commit-id: 5518583fce4629cd3ed605446a5f418f22d903d3 --- R_utils/model_eval.R | 4 +- examples/grocery_sales/R/01_dataprep.Rmd | 1 + examples/grocery_sales/R/01_dataprep.nb.html | 5 +- examples/grocery_sales/R/02_basic_models.Rmd | 6 +- .../grocery_sales/R/02_basic_models.nb.html | 12 +- examples/grocery_sales/R/02a_reg_models.Rmd | 3 +- .../grocery_sales/R/02a_reg_models.nb.html | 567 ++++++++---------- .../grocery_sales/R/02b_prophet_models.Rmd | 3 +- .../R/02b_prophet_models.nb.html | 9 +- examples/retail_turnover/01_explore.nb.html | 35 +- examples/retail_turnover/02_model.nb.html | 2 +- examples/retail_turnover/README.md | 17 +- 12 files changed, 319 insertions(+), 345 deletions(-) diff --git a/R_utils/model_eval.R b/R_utils/model_eval.R index a321ad58..5a919813 100644 --- a/R_utils/model_eval.R +++ b/R_utils/model_eval.R @@ -14,13 +14,13 @@ get_forecasts <- function(mable, newdata, ...) keyvars <- key_vars(fcast) keyvars <- keyvars[-length(keyvars)] indexvar <- index_var(fcast) - fcastvar <- as.character(attr(fcast, "response")[[1]]) + fcastvar <- names(fcast)[length(keyvars) + 3] fcast <- fcast %>% as_tibble() %>% pivot_wider( id_cols=all_of(c(keyvars, indexvar)), names_from=.model, - values_from=all_of(fcastvar)) + values_from=.mean) select(newdata, !!keyvars, !!indexvar, !!fcastvar) %>% rename(.response=!!fcastvar) %>% inner_join(fcast) diff --git a/examples/grocery_sales/R/01_dataprep.Rmd b/examples/grocery_sales/R/01_dataprep.Rmd index 05cd7d02..4e16e70c 100644 --- a/examples/grocery_sales/R/01_dataprep.Rmd +++ b/examples/grocery_sales/R/01_dataprep.Rmd @@ -69,6 +69,7 @@ library(ggplot2) oj_data %>% filter(store < 25, brand < 5) %>% + mutate(week=as.Date(week)) %>% ggplot(aes(x=week, y=logmove)) + geom_line() + scale_x_date(labels=NULL) + diff --git a/examples/grocery_sales/R/01_dataprep.nb.html b/examples/grocery_sales/R/01_dataprep.nb.html index bf37aa54..ee20fbda 100644 --- a/examples/grocery_sales/R/01_dataprep.nb.html +++ b/examples/grocery_sales/R/01_dataprep.nb.html @@ -332,11 +332,12 @@ oj_data <- orangeJuice$yx %>% - +
library(ggplot2)
 
 oj_data %>%
     filter(store < 25, brand < 5) %>%
+    mutate(week=as.Date(week)) %>%
     ggplot(aes(x=week, y=logmove)) +
         geom_line() +
         scale_x_date(labels=NULL) +
@@ -380,7 +381,7 @@ head(oj_train[[1]])
-
LS0tCnRpdGxlOiBEYXRhIHByZXBhcmF0aW9uCm91dHB1dDogaHRtbF9ub3RlYm9vawotLS0KCl9Db3B5cmlnaHQgKGMpIE1pY3Jvc29mdCBDb3Jwb3JhdGlvbi5fPGJyLz4KX0xpY2Vuc2VkIHVuZGVyIHRoZSBNSVQgTGljZW5zZS5fCgpJbiB0aGlzIG5vdGVib29rLCB3ZSBnZW5lcmF0ZSB0aGUgZGF0YXNldHMgdGhhdCB3aWxsIGJlIHVzZWQgZm9yIG1vZGVsIHRyYWluaW5nIGFuZCB2YWxpZGF0aW5nLiAKClRoZSBvcmFuZ2UganVpY2UgZGF0YXNldCBjb21lcyBmcm9tIHRoZSBiYXllc20gcGFja2FnZSwgYW5kIGdpdmVzIHByaWNpbmcgYW5kIHNhbGVzIGZpZ3VyZXMgb3ZlciB0aW1lIGZvciBhIHZhcmlldHkgb2Ygb3JhbmdlIGp1aWNlIGJyYW5kcyBpbiBzZXZlcmFsIHN0b3JlcyBpbiBGbG9yaWRhLiBSYXRoZXIgdGhhbiBpbnN0YWxsaW5nIHRoZSBlbnRpcmUgcGFja2FnZSAod2hpY2ggaXMgdmVyeSBjb21wbGV4KSwgd2UgZG93bmxvYWQgdGhlIGRhdGFzZXQgaXRzZWxmIGZyb20g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bmN0aW9uKGkpIHN1YnNldF9val9kYXRhKGkgKyBzZXR0aW5ncyRHQVAsIGkgKyBzZXR0aW5ncyRHQVAgKyBzZXR0aW5ncyRIT1JJWk9OIC0gMSkpCgpzYXZlKG9qX3RyYWluLCBval90ZXN0LCBmaWxlPWhlcmU6OmhlcmUoImV4YW1wbGVzL2dyb2Nlcnlfc2FsZXMvUi9kYXRhLlJkYXRhIikpCgpoZWFkKG9qX3RyYWluW1sxXV0pCgpoZWFkKG9qX3Rlc3RbWzFdXSkKYGBgCg==
diff --git a/examples/grocery_sales/R/02_basic_models.Rmd b/examples/grocery_sales/R/02_basic_models.Rmd index c12fc0e0..73702f20 100644 --- a/examples/grocery_sales/R/02_basic_models.Rmd +++ b/examples/grocery_sales/R/02_basic_models.Rmd @@ -53,7 +53,8 @@ oj_fcast_basic <- parallel::clusterMap(cl, get_forecasts, oj_modelset_basic, oj_ save_objects(oj_modelset_basic, oj_fcast_basic, example="grocery_sales", file="model_basic.Rdata") -do.call(rbind, oj_fcast_basic) %>% +oj_fcast_basic %>% + bind_rows() %>% mutate_at(-(1:3), exp) %>% eval_forecasts() ``` @@ -80,7 +81,8 @@ destroy_cluster(cl) save_objects(oj_modelset_ets, oj_fcast_ets, example="grocery_sales", file="model_ets.Rdata") -do.call(rbind, oj_fcast_ets) %>% +oj_fcast_ets %>% + bind_rows() %>% mutate_at(-(1:3), exp) %>% eval_forecasts() ``` diff --git a/examples/grocery_sales/R/02_basic_models.nb.html b/examples/grocery_sales/R/02_basic_models.nb.html index 6f91ee65..d0c9bfe8 100644 --- a/examples/grocery_sales/R/02_basic_models.nb.html +++ b/examples/grocery_sales/R/02_basic_models.nb.html @@ -247,7 +247,7 @@ summary {

This lets us speed up the training significantly. While the fable::model function can fit multiple models in parallel, we will run it sequentially here and instead parallelise by dataset. This avoids contention for cores, and also results in the simplest code. As a guard against returning invalid results, we also specify the argument .safely=FALSE; this forces model to throw an error if a model algorithm fails.

- +
srcdir <- here::here("R_utils")
 for(src in dir(srcdir, full.names=TRUE)) source(src)
 
@@ -270,7 +270,8 @@ oj_fcast_basic <- parallel::clusterMap(cl, get_forecasts, oj_modelset_basic,
 save_objects(oj_modelset_basic, oj_fcast_basic,
              example="grocery_sales", file="model_basic.Rdata")
 
-do.call(rbind, oj_fcast_basic) %>%
+oj_fcast_basic %>%
+    bind_rows() %>%
     mutate_at(-(1:3), exp) %>%
     eval_forecasts()
@@ -285,7 +286,7 @@ do.call(rbind, oj_fcast_basic) %>%

Having fit some basic models, we can also try an exponential smoothing model, fit using the ETS function. Unlike the others, ETS does not currently support time series with missing values; we therefore have to use one of the other models to impute missing values first via the interpolate function.

- +
oj_modelset_ets <- parallel::clusterMap(cl, function(df, basicmod)
 {
     df %>%
@@ -303,7 +304,8 @@ destroy_cluster(cl)
 save_objects(oj_modelset_ets, oj_fcast_ets,
              example="grocery_sales", file="model_ets.Rdata")
 
-do.call(rbind, oj_fcast_ets) %>%
+oj_fcast_ets %>%
+    bind_rows() %>%
     mutate_at(-(1:3), exp) %>%
     eval_forecasts()
@@ -317,7 +319,7 @@ do.call(rbind, oj_fcast_ets) %>%

The ETS model does worse than the ARIMA model, something that should not be a surprise given the lack of strong seasonality and trend in this dataset. We conclude that any simple univariate approach is unlikely to do well.

-
LS0tCnRpdGxlOiBCYXNpYyBtb2RlbHMKb3V0cHV0OiBodG1sX25vdGVib29rCi0tLQoKX0NvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLl88YnIvPgpfTGljZW5zZWQgdW5kZXIgdGhlIE1JVCBMaWNlbnNlLl8KCmBgYHtyLCBlY2hvPUZBTFNFLCByZXN1bHRzPSJoaWRlIiwgbWVzc2FnZT1GQUxTRX0KbGlicmFyeSh0aWR5cikKbGlicmFyeShkcGx5cikKbGlicmFyeSh0c2liYmxlKQpsaWJyYXJ5KGZlYXN0cykKbGlicmFyeShmYWJsZSkKYGBgCgpXZSBmaXQgc29tZSBzaW1wbGUgbW9kZWxzIHRvIHRoZS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MsIG9qX3Rlc3QpCgpkZXN0cm95X2NsdXN0ZXIoY2wpCgpzYXZlX29iamVjdHMob2pfbW9kZWxzZXRfZXRzLCBval9mY2FzdF9ldHMsCiAgICAgICAgICAgICBleGFtcGxlPSJncm9jZXJ5X3NhbGVzIiwgZmlsZT0ibW9kZWxfZXRzLlJkYXRhIikKCm9qX2ZjYXN0X2V0cyAlPiUKICAgIGJpbmRfcm93cygpICU+JQogICAgbXV0YXRlX2F0KC0oMTozKSwgZXhwKSAlPiUKICAgIGV2YWxfZm9yZWNhc3RzKCkKYGBgCgpUaGUgRVRTIG1vZGVsIGRvZXMgX3dvcnNlXyB0aGFuIHRoZSBBUklNQSBtb2RlbCwgc29tZXRoaW5nIHRoYXQgc2hvdWxkIG5vdCBiZSBhIHN1cnByaXNlIGdpdmVuIHRoZSBsYWNrIG9mIHN0cm9uZyBzZWFzb25hbGl0eSBhbmQgdHJlbmQgaW4gdGhpcyBkYXRhc2V0LiBXZSBjb25jbHVkZSB0aGF0IGFueSBzaW1wbGUgdW5pdmFyaWF0ZSBhcHByb2FjaCBpcyB1bmxpa2VseSB0byBkbyB3ZWxsLgo=
diff --git a/examples/grocery_sales/R/02a_reg_models.Rmd b/examples/grocery_sales/R/02a_reg_models.Rmd index a2d790a3..19fbfa42 100644 --- a/examples/grocery_sales/R/02a_reg_models.Rmd +++ b/examples/grocery_sales/R/02a_reg_models.Rmd @@ -79,7 +79,8 @@ destroy_cluster(cl) save_objects(oj_modelset_reg, oj_fcast_reg, example="grocery_sales", file="model_reg.Rdata") -do.call(rbind, oj_fcast_reg) %>% +oj_fcast_reg %>% + bind_rows() %>% mutate_at(-(1:3), exp) %>% eval_forecasts() ``` diff --git a/examples/grocery_sales/R/02a_reg_models.nb.html b/examples/grocery_sales/R/02a_reg_models.nb.html index dea3ef98..c50c4b31 100644 --- a/examples/grocery_sales/R/02a_reg_models.nb.html +++ b/examples/grocery_sales/R/02a_reg_models.nb.html @@ -4,228 +4,194 @@ - - - - - - - ARIMA-Regression models - - - - - - - - - - - - - - - - - - - - - - + + + - - - + + + - - - .tabset-dropdown>.nav-tabs>li.active:before { - content: ""; - font-family: 'Glyphicons Halflings'; - display: inline-block; - padding: 10px; - border-right: 1px solid #ddd; - } - .tabset-dropdown>.nav-tabs.nav-tabs-open>li.active:before { - content: ""; - border: none; - } - .tabset-dropdown>.nav-tabs.nav-tabs-open:before { - content: ""; - font-family: 'Glyphicons Halflings'; - display: inline-block; - padding: 10px; - border-right: 1px solid #ddd; - } - .tabset-dropdown>.nav-tabs>li.active { - display: block; - } + - .tabset-dropdown>.nav-tabs>li>a, - .tabset-dropdown>.nav-tabs>li>a:focus, - .tabset-dropdown>.nav-tabs>li>a:hover { - border: none; - display: inline-block; - border-radius: 4px; - background-color: transparent; - } + +.kable-table table>thead>tr>th { + border: none; + border-bottom: 2px solid #dddddd; +} - - +.kable-table table>thead { + background-color: #fff; +} + + + + + + + + + @@ -235,55 +201,48 @@ -
+
- - -

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

- - - - -

This notebook builds on the output from “Basic models” by including regressor variables in the ARIMA model(s). We - fit the following model types:

-
    -
  • ar_trend includes only a linear trend over time.
  • -
  • ar_reg allows stepwise selection of independent regressors.
  • -
  • ar_reg_price: rather than allowing the algorithm to select from the 11 price variables, we use - only the price relevant to each brand. This is to guard against possible overfitting, something that classical - stepwise procedures are wont to do.
  • -
  • ar_reg_price_trend is the same as ar_reg_price, but including a linear trend.
  • -
-

As part of the modelling, we also compute a new independent variable maxpricediff, the log-ratio of - the price of this brand compared to the best competing price. A positive maxpricediff means this - brand is cheaper than all the other brands, and a negative maxpricediff means it is more expensive. -

- - - -
srcdir <- here::here("R_utils")
+
+

Copyright (c) Microsoft Corporation.
Licensed under the MIT License.

+ + + + +

This notebook builds on the output from “Basic models” by including regressor variables in the ARIMA model(s). We fit the following model types:

+
    +
  • ar_trend includes only a linear trend over time.
  • +
  • ar_reg allows stepwise selection of independent regressors.
  • +
  • ar_reg_price: rather than allowing the algorithm to select from the 11 price variables, we use only the price relevant to each brand. This is to guard against possible overfitting, something that classical stepwise procedures are wont to do.
  • +
  • ar_reg_price_trend is the same as ar_reg_price, but including a linear trend.
  • +
+

As part of the modelling, we also compute a new independent variable maxpricediff, the log-ratio of the price of this brand compared to the best competing price. A positive maxpricediff means this brand is cheaper than all the other brands, and a negative maxpricediff means it is more expensive.

+ + + +
srcdir <- here::here("R_utils")
 for(src in dir(srcdir, full.names=TRUE)) source(src)
 
 load_objects("grocery_sales", "data.Rdata")
@@ -337,87 +296,83 @@ destroy_cluster(cl)
 save_objects(oj_modelset_reg, oj_fcast_reg,
              example="grocery_sales", file="model_reg.Rdata")
 
-do.call(rbind, oj_fcast_reg) %>%
+oj_fcast_reg %>%
+    bind_rows() %>%
     mutate_at(-(1:3), exp) %>%
     eval_forecasts()
- -
- -
- - -

This shows that the models incorporating price are a significant improvement over the previous naive models. The - model that uses stepwise selection to choose the best price variable does worse than the one where we choose the - price beforehand, confirming the suspicion that stepwise leads to overfitting in this case.

- +
+ + +

This shows that the models incorporating price are a significant improvement over the previous naive models. The model that uses stepwise selection to choose the best price variable does worse than the one where we choose the price beforehand, confirming the suspicion that stepwise leads to overfitting in this case.

+ -
- LS0tCnRpdGxlOiBBUklNQS1SZWdyZXNzaW9uIG1vZGVscwpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sKLS0tCgpfQ29weXJpZ2h0IChjKSBNaWNyb3NvZnQgQ29ycG9yYXRpb24uXzxici8+Cl9MaWNlbnNlZCB1bmRlciB0aGUgTUlUIExpY2Vuc2UuXwoKYGBge3IsIGVjaG89RkFMU0UsIHJlc3VsdHM9ImhpZGUiLCBtZXNzYWdlPUZBTFNFfQpsaWJyYXJ5KHRpZHlyKQpsaWJyYXJ5KGRwbHlyKQpsaWJyYXJ5KHRzaWJibGUpCmxpYnJhcnkoZmVhc3RzKQpsaWJyYXJ5KGZhYmxlKQpgYGAKClRoaXMgbm90ZWJvb2sgYnVpbGRzIG9uIHRoZS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gb3ZlciB0aGUgcHJldmlvdXMgbmFpdmUgbW9kZWxzLiBUaGUgbW9kZWwgdGhhdCB1c2VzIHN0ZXB3aXNlIHNlbGVjdGlvbiB0byBjaG9vc2UgdGhlIGJlc3QgcHJpY2UgdmFyaWFibGUgZG9lcyB3b3JzZSB0aGFuIHRoZSBvbmUgd2hlcmUgd2UgY2hvb3NlIHRoZSBwcmljZSBiZWZvcmVoYW5kLCBjb25maXJtaW5nIHRoZSBzdXNwaWNpb24gdGhhdCBzdGVwd2lzZSBsZWFkcyB0byBvdmVyZml0dGluZyBpbiB0aGlzIGNhc2UuCg==
-
+ - + - + - +$(document).ready(function () { + $('.tabset-dropdown > .nav-tabs > li').click(function () { + $(this).parent().toggleClass('nav-tabs-open') + }); +}); + - - + + - - + + - - \ No newline at end of file + diff --git a/examples/grocery_sales/R/02b_prophet_models.Rmd b/examples/grocery_sales/R/02b_prophet_models.Rmd index 13d33f94..35754ecc 100644 --- a/examples/grocery_sales/R/02b_prophet_models.Rmd +++ b/examples/grocery_sales/R/02b_prophet_models.Rmd @@ -64,7 +64,8 @@ destroy_cluster(cl) save_objects(oj_modelset_pr, oj_fcast_pr, example="grocery_sales", file="model_pr.Rdata") -do.call(rbind, oj_fcast_pr) %>% +oj_fcast_pr %>% + bind_rows() %>% mutate_at(-(1:3), exp) %>% eval_forecasts() ``` diff --git a/examples/grocery_sales/R/02b_prophet_models.nb.html b/examples/grocery_sales/R/02b_prophet_models.nb.html index 4bf9ae60..7ec4e08c 100644 --- a/examples/grocery_sales/R/02b_prophet_models.nb.html +++ b/examples/grocery_sales/R/02b_prophet_models.nb.html @@ -238,7 +238,7 @@ summary {

Here, we will use the fable.prophet package which provides a tidyverts frontend to the prophet package itself. As with ETS, prophet does not support time series with missing values, so we again impute them using the ARIMA model forecasts.

- +
srcdir <- here::here("R_utils")
 for(src in dir(srcdir, full.names=TRUE)) source(src)
 
@@ -275,13 +275,14 @@ destroy_cluster(cl)
 save_objects(oj_modelset_pr, oj_fcast_pr,
              example="grocery_sales", file="model_pr.Rdata")
 
-do.call(rbind, oj_fcast_pr) %>%
+oj_fcast_pr %>%
+    bind_rows() %>%
     mutate_at(-(1:3), exp) %>%
     eval_forecasts()
@@ -289,7 +290,7 @@ do.call(rbind, oj_fcast_pr) %>%

It appears that Prophet does not do better than the simple ARIMA model with regression variables. This is possibly because the dataset does not have a strong time series nature: there is no seasonality, and only weak or nonexistent trends. These are features which the Prophet algorithm is designed to detect, and their absence means that there would be little advantage in using it.

-
LS0tCnRpdGxlOiBQcm9waGV0IG1vZGVscwpvdXRwdXQ6IGh0bWxfbm90ZWJvb2sKLS0tCgpfQ29weXJpZ2h0IChjKSBNaWNyb3NvZnQgQ29ycG9yYXRpb24uXzxici8+Cl9MaWNlbnNlZCB1bmRlciB0aGUgTUlUIExpY2Vuc2UuXwoKYGBge3IsIGVjaG89RkFMU0UsIHJlc3VsdHM9ImhpZGUiLCBtZXNzYWdlPUZBTFNFfQpsaWJyYXJ5KHRpZHlyKQpsaWJyYXJ5KGRwbHlyKQpsaWJyYXJ5KHRzaWJibGUpCmxpYnJhcnkoZmVhc3RzKQpsaWJyYXJ5KGZhYmxlKQpsaWJyYXJ5KHByb3BoZXQpCmxpYnJhcnkoZmFibGUucHJvcGhldCkKYGBgCgpUaGlzIG5vdGVib29rIGJ1aWxkcyBhIGZvcmVjYXN0aW5nIG1vZGVsIHVzaW5nIHRoZSBbUHJvcGhldF0oaHR0cHM6Ly9mYWNlYm9vay5naXRodWIuaW8vcHJvcGhldC8pIGFsZ29yaXRobS4gUHJvcGhldCBpcyBhIHRpbWUgc2VyaWVzIG1vZGVsIGRldmVsb3BlZCBieSBGYWNlYm9vayB0aGF0IGlzIGRlc2lnbmVkIHRvIGJlIHNpbXBsZSBmb3Igbm9uLWV4cGVydHMgdG8gdXNlLCB5ZXQgZmxleGlibGUgYW5kIHBvd2VyZnVsLgoKPiBQcm9waGV0IGlzIGEgcHJvY2VkdXJlIGZvciBmb3JlY2FzdGluZyB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zdF9mdW5jPWdldF9mb3JlY2FzdHMpKQoKZGVzdHJveV9jbHVzdGVyKGNsKQoKc2F2ZV9vYmplY3RzKG9qX21vZGVsc2V0X3ByLCBval9mY2FzdF9wciwKICAgICAgICAgICAgIGV4YW1wbGU9Imdyb2Nlcnlfc2FsZXMiLCBmaWxlPSJtb2RlbF9wci5SZGF0YSIpCgpval9mY2FzdF9wciAlPiUKICAgIGJpbmRfcm93cygpICU+JQogICAgbXV0YXRlX2F0KC0oMTozKSwgZXhwKSAlPiUKICAgIGV2YWxfZm9yZWNhc3RzKCkKYGBgCgpJdCBhcHBlYXJzIHRoYXQgUHJvcGhldCBkb2VzIF9ub3RfIGRvIGJldHRlciB0aGFuIHRoZSBzaW1wbGUgQVJJTUEgbW9kZWwgd2l0aCByZWdyZXNzaW9uIHZhcmlhYmxlcy4gVGhpcyBpcyBwb3NzaWJseSBiZWNhdXNlIHRoZSBkYXRhc2V0IGRvZXMgbm90IGhhdmUgYSBzdHJvbmcgdGltZSBzZXJpZXMgbmF0dXJlOiB0aGVyZSBpcyBubyBzZWFzb25hbGl0eSwgYW5kIG9ubHkgd2VhayBvciBub25leGlzdGVudCB0cmVuZHMuIFRoZXNlIGFyZSBmZWF0dXJlcyB3aGljaCB0aGUgUHJvcGhldCBhbGdvcml0aG0gaXMgZGVzaWduZWQgdG8gZGV0ZWN0LCBhbmQgdGhlaXIgYWJzZW5jZSBtZWFucyB0aGF0IHRoZXJlIHdvdWxkIGJlIGxpdHRsZSBhZHZhbnRhZ2UgaW4gdXNpbmcgaXQuCg==
diff --git a/examples/retail_turnover/01_explore.nb.html b/examples/retail_turnover/01_explore.nb.html index 862fde50..0fa8e493 100644 --- a/examples/retail_turnover/01_explore.nb.html +++ b/examples/retail_turnover/01_explore.nb.html @@ -236,12 +236,33 @@ summary {

Let’s look at how to do some simple summaries. We’ll use the aus_retail dataset, which contains retail turnover statistics by (Australian) state and industry, going back to 1982. This is part of the tsibbledata package, which contains several example time series datasets.

- -
library(dplyr)
-library(tsibbledata)
+
+
library(dplyr)
+ + +

+Attaching package: 'dplyr'
+ + +
The following objects are masked from 'package:stats':
+
+    filter, lag
+ + +
The following objects are masked from 'package:base':
+
+    intersect, setdiff, setequal, union
+ + +
library(tsibbledata)
 library(tsibble)
-library(feasts)
-library(fable)
+library(feasts)
+ + +
Loading required package: fabletools
+ + +
library(fable)
 
 slice(aus_retail, 1:6)
@@ -303,7 +324,7 @@ Industry
@@ -317,7 +338,7 @@ Industry
diff --git a/examples/retail_turnover/02_model.nb.html b/examples/retail_turnover/02_model.nb.html index 6cc10ce8..da7163fc 100644 --- a/examples/retail_turnover/02_model.nb.html +++ b/examples/retail_turnover/02_model.nb.html @@ -290,7 +290,7 @@ fcasts %>% theme(legend.position="bottom") -

+

diff --git a/examples/retail_turnover/README.md b/examples/retail_turnover/README.md index c9a24a93..d3f5a53b 100644 --- a/examples/retail_turnover/README.md +++ b/examples/retail_turnover/README.md @@ -21,24 +21,13 @@ The following packages and their dependencies are needed to run the notebooks in | Tidyverse | dplyr, tidyr, ggplot2 | | Tidyverts | tsibble, tsibbledata, fabletools, fable, feasts | | Future | future, future.apply | -| Other | urca, rmarkdown, distributional, devtools (see below) | - -It's likely that you will already have many of these (particularly the Tidyverse packages) installed. However, currently (June 2020) the notebooks do require the _development_ versions of the Tidyverts packages; these can be installed from GitHub using the devtools package. +| Other | urca, rmarkdown | ```r -install.packages("tidyverse") +install.packages("tidyverse") # installs all Tidyverse packages install.packages(c("future", "future.apply")) install.packages(c("rmarkdown", "urca")) - -# install Tidyverts packages from GitHub -install.packages("devtools") - -devtools::install_github("tidyverts/tsibble@a19cda281c3f1e0061b5b0de93b059c52052ebda") -devtools::install_github("tidyverts/tsibbledata@b06a965b788722157a149296c47f821c99cc41f0") -devtools::install_github("mitchelloharawild/distributional@e668b520b415f417f71eacd7e1e940561eecffd6") -devtools::install_github("tidyverts/fabletools@864b2daa983446017f2ed757a3b8889b935cc2cb") -devtools::install_github("tidyverts/fable@d2600c151fde1609cc491d8f94bd136c71f87523") -devtools::install_github("tidyverts/feasts@f006746effa10bc223479441ebede136ca016b11") +install.packages(c("tsibble", "tsibbledata", "fabletools", "fable", "feasts")) ``` ## Acknowledgements