Creating a Reproducible Example
Based on a similar post by Rob Hyndman.
A Minimal Reproducible Example is intended to reproduce a point using the smallest amount of code. It uses default data or includes the data.
# packages to reproduce the problem
library(seasonal)
# data to reproduce the problem
# the following code is produced by `dput(mdeaths)`
y <- structure(c(2134, 1863, 1877, 1877, 1492, 1249, 1280, 1131, 1209,
1492, 1621, 1846, 2103, 2137, 2153, 1833, 1403, 1288, 1186, 1133,
1053, 1347, 1545, 2066, 2020, 2750, 2283, 1479, 1189, 1160, 1113,
970, 999, 1208, 1467, 2059, 2240, 1634, 1722, 1801, 1246, 1162,
1087, 1013, 959, 1179, 1229, 1655, 2019, 2284, 1942, 1423, 1340,
1187, 1098, 1004, 970, 1140, 1110, 1812, 2263, 1820, 1846, 1531,
1215, 1075, 1056, 975, 940, 1081, 1294, 1341), .Tsp = c(1974,
1979.91666666667, 12), class = "ts")
# the problem
# here: X11 and SEATS lead to different result
ts.plot(cbind(
final(seas(y, x11 = "")),
final(seas(y))
), col = 1:2)
It should consist of a single piece of R code that replicates the problem. It should contain the following sections:
- Packages to be loaded, including
library(seasonal)
. - The shortest amount of code that reproduces the issue.
- The data needed to run the code.
Try to use one of the built-in datasets if possible, AirPassengers
works
great.
If you need to include your data, use dput()
so the data can
be included as part of the same text file. For example, if you have a time
series y
, it can be included in your code by running dput(y)
, copying the
output, and then in the text file type y <-
then paste.
A Minimal Reproducible Example should be copyable to the R console and work out of the box. The best way to ensure it is reproducible is to use the reprex package.
Generally, I prefer resolving issues via GitHub, because it simplifies tracking and allows other people to benefit from the discussion.
A more detailed discussion on reproducibility can be found here.