# devtools::install_github("christophsax/tsbox")
library(tsbox)
stopifnot(packageVersion("tsbox") >= "0.0.11.2")
suppressMessages(library(tidyverse))
library(wbstats)
# # Search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' Secondary Axis in ggplot2 | |
| #' | |
| #' To use a secondary axis in ggplot, the data shown on the right axis needs to | |
| #' be transformed. Use `sec_scale` to calculate the scale adjutments. Use | |
| #' `apply_sec_scale` to apply the scale adjutments within ggplot. See | |
| #' examples. | |
| #' | |
| #' @param df1 a ts-boxable object, plotted on the left axis | |
| #' @param df2 a ts-boxable object, plotted on the right axis | |
| #' @param x numeric vector |
### Preparing the Time Trip
library(timemachine)
# assuming EXP is available one period before
# (for demonstration only)
swiss_history2 <- swiss_history %>%
mutate(pub_date = if_else(var == "EXP", add_to_date(pub_date, "-1 quarter"), pub_date)) %>%
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ``` r | |
| library(seasonal) | |
| m <- seas(AirPassengers, regression.variables = c("const", "seasonal"), regression.aictest = NULL) | |
| monthplot(m) | |
| ``` | |
|  | |
| ``` r |
library(seasonal)10 Year Forecast of AirPassengers seasonality
m <- seas(AirPassengers, x11.appendfcst = "yes", forecast.maxlead = 120)
plot(series(m, "x11.adjustfac"))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Some speed comparison of fwrite and feather: | |
| library(data.table) | |
| library(feather) | |
| # On an AWS EC2 m4.10xlarge with 40 cores: | |
| # with 100 mio | |
| size <- 100000000 | |
| iris2 <- data.table(iris[sample(1:nrow(iris), size, replace = TRUE), ]) |
NewerOlder