{"id":28560278,"url":"https://github.com/ellisp/ggseas","last_synced_at":"2025-06-10T09:08:03.593Z","repository":{"id":56937235,"uuid":"51270668","full_name":"ellisp/ggseas","owner":"ellisp","description":"seasonal adjustment on the fly extension for ggplot2","archived":false,"fork":false,"pushed_at":"2025-06-02T04:58:16.000Z","size":1425,"stargazers_count":75,"open_issues_count":4,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-02T09:17:57.929Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ellisp.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-07T23:00:43.000Z","updated_at":"2025-04-15T23:45:25.000Z","dependencies_parsed_at":"2022-08-21T01:00:09.448Z","dependency_job_id":null,"html_url":"https://github.com/ellisp/ggseas","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ellisp%2Fggseas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ellisp%2Fggseas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ellisp%2Fggseas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ellisp%2Fggseas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ellisp","download_url":"https://codeload.github.com/ellisp/ggseas/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ellisp%2Fggseas/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259043782,"owners_count":22797164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-10T09:08:01.788Z","updated_at":"2025-06-10T09:08:03.580Z","avatar_url":"https://github.com/ellisp.png","language":"R","funding_links":[],"categories":["Data and models"],"sub_categories":[],"readme":"# ggseas R package\nseasonal adjustment on the fly extension for ggplot2\n\nConvenience functions that let you easily do seasonal adjustment on the fly with ggplot.\n\nDepends on the [`seasonal` package](https://cran.r-project.org/web/packages/seasonal/index.html) to give you access to X13-SEATS-ARIMA.\n\n[![Travis-CI Build Status](https://travis-ci.org/ellisp/ggseas.svg?branch=master)](https://travis-ci.org/ellisp/ggseas)\n[![CRAN version](http://www.r-pkg.org/badges/version/ggseas)](http://www.r-pkg.org/pkg/ggseas)\n[![CRAN RStudio mirror downloads](http://cranlogs.r-pkg.org/badges/ggseas)](http://www.r-pkg.org/pkg/ggseas)\n\n\n## Installation\nInstall the stable version the usual way from CRAN:\n\n```{r, eval = FALSE}\ninstall.packages(\"ggseas\")\n```\n\n\nor the latest version (bugs and all) from GitHub:\n```{r, eval = FALSE}\ndevtools::install_github(\"ellisp/ggseas/pkg\")\n```\n\n\n## Usage - seasonal adjustment on the fly\nSo far there are three types of seasonal adjustment possible to be incorporated\ninto a usual ggplot() command, substituting for where you'd normally have geom_line().\n\n### X13-SEATS-ARIMA\n```{r}\nlibrary(ggseas)\n# make demo data with the convenience \"time series to data.frame\" function tsdf()\nap_df \u003c- tsdf(AirPassengers)\n\n# SEATS with defaults\nggplot(ap_df, aes(x = x, y = y)) +\n   geom_line(colour = \"grey80\") +\n   stat_seas() +\n   ggtitle(\"SEATS seasonal adjustment - international airline passengers\") +\n   ylab(\"International airline passengers per month\")\n\n# X11 with no outlier treatment\nggplot(ap_df, aes(x = x, y = y)) +\n   geom_line(colour = \"grey80\") +\n   stat_seas(x13_params = list(x11 = \"\", outlier = NULL)) +\n   ggtitle(\"X11 seasonal adjustment - international airline passengers\") +\n   ylab(\"International airline passengers per month\")\n\nggplot(ldeaths_df, aes(x = YearMon, y = deaths, colour = sex)) +\n   geom_point(colour = \"grey50\") +\n   geom_line(colour = \"grey50\") +\n   facet_wrap(~sex) +\n   stat_seas(size = 2) +\n   ggtitle(\"Seasonally adjusted lung deaths in the UK 1974 - 1979\") +\n   ylab(\"Deaths\") +\n   xlab(\"(light grey shows original data;\\ncoloured line is seasonally adjusted)\") +\n   theme(legend.position = \"none\")\n```\n\n### STL (LOESS-based decomposition)\n```{r}\n# periodic if fixed seasonality; doesn't work well:\nggplot(ap_df, aes(x = x, y = y)) +\n   geom_line(colour = \"grey80\") +\n   stat_stl(s.window = \"periodic\")\n\n# seasonality varies a bit over time, works better:\nggplot(ap_df, aes(x = x, y = y)) +\n   geom_line(colour = \"grey80\") +\n   stat_stl(s.window = 7)\n```\n\n### Classical decomposition\n```{r}\n# default additive decomposition (doesn't work well in this case!):\nggplot(ap_df, aes(x = x, y = y)) +\n   geom_line(colour = \"grey80\") +\n   stat_decomp()\n\n# multiplicative decomposition, more appropriate:\nggplot(ap_df, aes(x = x, y = y)) +\n   geom_line(colour = \"grey80\") +\n   stat_decomp(type = \"multiplicative\")\n```\n\n## Usage - seasonal decomposition on the fly\nFrom version 0.2.0 I introduce a summary graphic decomposition, similar to what\nyou'd get with plot(stats::decompose(x)), but in the ggplot2 environment.  As well\nas allowing ggplot2 look and feel of plots, you can also map a variable to the \ncolour (or color) aesthetic, to allow two difference decompositions on the same\ngraphic.\n```{r}\nggsdc(ap_df, aes(x = x, y = y), method = \"decompose\") +\n   geom_line()\n\n\nggsdc(ap_df, aes(x = x, y = y), method = \"stl\", s.window = 7) +\n   labs(x = \"\", y = \"Air passenger numbers\") +\n   geom_point()\n\nggsdc(ldeaths_df, aes(x = YearMon, y = deaths, colour = sex), method = \"seas\") +\n      geom_line()\n\nlibrary(scales) # for label= comma\nserv \u003c- subset(nzbop, Account == \"Current account\" \u0026 \n                  Category %in% c(\"Services; Exports total\", \"Services; Imports total\"))\n\nggsdc(serv, aes(x = TimePeriod, y = Value, colour = Category),\n      method = \"seas\", start = c(1971, 2), frequency = 4) +\n   geom_line() +\n   scale_y_continuous(\"NZ$ millions\\ndecomposition by X13-SEATS-ARIMA\", label = comma) +\n   labs(x = \"\") +\n   ggtitle(\"New Zealand services balance of payments -\\ngreater seasonality in exports than imports\") +\n   theme_light()\n\n```\n\nComing in 0.5.0 - control facet titles during seasonal decomposition on the fly\n\n```{r}\n   ggsdc(serv, aes(x = TimePeriod, y = Value, colour = Category),\n         method = \"stl\", s.window = 7, frequency = 4,\n         facet.titles = c(\"The original series\", \"The underlying trend\", \"Regular seasonal patterns\", \"All the randomness left\")) +\n      geom_line()\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fellisp%2Fggseas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fellisp%2Fggseas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fellisp%2Fggseas/lists"}