{"id":13857313,"url":"https://github.com/rafzamb/sknifedatar","last_synced_at":"2026-03-07T14:03:00.589Z","repository":{"id":51278615,"uuid":"323522493","full_name":"rafzamb/sknifedatar","owner":"rafzamb","description":"sknifedatar is a package that serves primarily as an extension to the modeltime 📦 ecosystem. In addition to some functionalities of spatial data and visualization.","archived":false,"fork":false,"pushed_at":"2023-02-06T21:43:02.000Z","size":35650,"stargazers_count":37,"open_issues_count":5,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-22T04:52:38.112Z","etag":null,"topics":["data","data-analysis","data-science","data-visualization","forecasting","r","statistics","time-series"],"latest_commit_sha":null,"homepage":"https://rafzamb.github.io/sknifedatar/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rafzamb.png","metadata":{"files":{"readme":"README.md","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,"governance":null}},"created_at":"2020-12-22T04:42:06.000Z","updated_at":"2024-09-03T08:32:15.000Z","dependencies_parsed_at":"2023-09-22T07:18:44.481Z","dependency_job_id":null,"html_url":"https://github.com/rafzamb/sknifedatar","commit_stats":{"total_commits":159,"total_committers":6,"mean_commits":26.5,"dds":"0.25786163522012584","last_synced_commit":"af29fe7e755ba926f4c6203bcb936dc225813310"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rafzamb/sknifedatar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafzamb%2Fsknifedatar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafzamb%2Fsknifedatar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafzamb%2Fsknifedatar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafzamb%2Fsknifedatar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafzamb","download_url":"https://codeload.github.com/rafzamb/sknifedatar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafzamb%2Fsknifedatar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30216498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T13:35:13.914Z","status":"ssl_error","status_checked_at":"2026-03-07T13:35:13.569Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["data","data-analysis","data-science","data-visualization","forecasting","r","statistics","time-series"],"created_at":"2024-08-05T03:01:33.154Z","updated_at":"2026-03-07T14:02:55.577Z","avatar_url":"https://github.com/rafzamb.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n# sknifedatar :package: “Swiss Knife of Data for R” \u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"139\"/\u003e\n\n\u003c!-- badges: start --\u003e\n\n[![CRAN\nstatus](https://www.r-pkg.org/badges/version/sknifedatar)](https://CRAN.R-project.org/package=sknifedatar)\n[![Total\nDownloads](http://cranlogs.r-pkg.org/badges/grand-total/sknifedatar?color=brightgreen)](https://cran.r-project.org/package=sknifedatar)\n![](http://cranlogs.r-pkg.org/badges/sknifedatar?color=brightgreen)\n\n\u003c!-- badges: end --\u003e\n\n\u003e Serves primarily as an extension to the\n\u003e [modeltime](https://business-science.github.io/modeltime/) :package:\n\u003e ecosystem. In addition to some functionalities of spatial data and\n\u003e visualization.\n\n## Installation\n\nCRAN version:\n\n``` r\ninstall.packages(\"sknifedatar\")\n```\n\nOr install the development version from GitHub with:\n\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"rafzamb/sknifedatar\")\n```\n\n## Features:  \n\n-   multifit: multiple models into multiple time series (no panel).\n-   workflowsets: [worklowset over a time\n    series](https://rafzamb.github.io/sknifedatar/articles/workflowsets_times.html).\n-   workflowset multifit: [worklowset over multiple time series (no\n    panel)](https://rafzamb.github.io/sknifedatar/articles/workflowsets_multi_times.html).\n-   automagic tabs: [automatic generation of Tabs in Distill/Rmarkdown\n    files](https://rafzamb.github.io/sknifedatar/articles/automatic_tabs.html).\n-   sliding windows: [data partitioning in sliding\n    windows](https://rafzamb.github.io/sknifedatar/articles/sliding_windows.html).\n\n## Usage\n\n### Fit multiple models into multiple time series.\n\n\u003cimg src=\"man/figures/diagrama_resumen_en.png\" width=\"100%\" style=\"display: block; margin: auto;\" /\u003e\n\n### libraries\n\n``` r\n library(modeltime)\n library(rsample)\n library(parsnip)\n library(recipes)\n library(workflows)\n library(dplyr)\n library(tidyr)\n library(sknifedatar)\n```\n\n### Data\n\n``` r\ndata(\"emae_series\")\nnested_serie = emae_series %\u003e% filter(date \u003c '2020-02-01') %\u003e% nest(nested_column=-sector)\n \nnested_serie\n#\u003e # A tibble: 16 x 2\n#\u003e    sector                           nested_column     \n#\u003e    \u003cchr\u003e                            \u003clist\u003e            \n#\u003e  1 Comercio                         \u003ctibble [193 × 2]\u003e\n#\u003e  2 Ensenanza                        \u003ctibble [193 × 2]\u003e\n#\u003e  3 Administracion publica           \u003ctibble [193 × 2]\u003e\n#\u003e  4 Transporte y comunicaciones      \u003ctibble [193 × 2]\u003e\n#\u003e  5 Servicios sociales/Salud         \u003ctibble [193 × 2]\u003e\n#\u003e  6 Impuestos netos                  \u003ctibble [193 × 2]\u003e\n#\u003e  7 Sector financiero                \u003ctibble [193 × 2]\u003e\n#\u003e  8 Mineria                          \u003ctibble [193 × 2]\u003e\n#\u003e  9 Agro/Ganaderia/Caza/Silvicultura \u003ctibble [193 × 2]\u003e\n#\u003e 10 Electricidad/Gas/Agua            \u003ctibble [193 × 2]\u003e\n#\u003e 11 Hoteles/Restaurantes             \u003ctibble [193 × 2]\u003e\n#\u003e 12 Inmobiliarias                    \u003ctibble [193 × 2]\u003e\n#\u003e 13 Otras actividades                \u003ctibble [193 × 2]\u003e\n#\u003e 14 Pesca                            \u003ctibble [193 × 2]\u003e\n#\u003e 15 Industria manufacturera          \u003ctibble [193 × 2]\u003e\n#\u003e 16 Construccion                     \u003ctibble [193 × 2]\u003e\n```\n\n### Recipes\n\n``` r\nrecipe_1 = recipe(value ~ ., data = emae_series %\u003e% select(-sector)) %\u003e%\n  step_date(date, features = c(\"month\", \"quarter\", \"year\"), ordinal = TRUE)\n```\n\n### Models\n\n``` r\n m_auto_arima \u003c- arima_reg() %\u003e% set_engine('auto_arima')\n\n m_stlm_arima \u003c- seasonal_reg() %\u003e%\n   set_engine(\"stlm_arima\")\n\n m_nnetar \u003c- workflow() %\u003e%\n   add_recipe(recipe_1) %\u003e%\n   add_model(nnetar_reg() %\u003e% set_engine(\"nnetar\"))\n```\n\n### modeltime\\_multifit()\n\n``` r\n model_table_emae \u003c- modeltime_multifit(serie = nested_serie %\u003e% head(3),\n                                       .prop = 0.8,\n                                       m_auto_arima,\n                                       m_stlm_arima,\n                                       m_nnetar)\n#\u003e Registered S3 method overwritten by 'tune':\n#\u003e   method                   from   \n#\u003e   required_pkgs.model_spec parsnip\n#\u003e frequency = 12 observations per 1 year\n#\u003e frequency = 12 observations per 1 year\n#\u003e frequency = 12 observations per 1 year\n#\u003e frequency = 12 observations per 1 year\n#\u003e frequency = 12 observations per 1 year\n#\u003e frequency = 12 observations per 1 year\n#\u003e frequency = 12 observations per 1 year\n#\u003e frequency = 12 observations per 1 year\n#\u003e frequency = 12 observations per 1 year\n#\u003e \n#\u003e ── 3 models fitted ♥ ───────────────────────────────────────────────────────────\n\n model_table_emae\n#\u003e $table_time\n#\u003e # A tibble: 3 x 7\n#\u003e   sector       nested_column   m_auto_arima m_stlm_arima m_nnetar nested_model  \n#\u003e   \u003cchr\u003e        \u003clist\u003e          \u003clist\u003e       \u003clist\u003e       \u003clist\u003e   \u003clist\u003e        \n#\u003e 1 Comercio     \u003ctibble [193 ×… \u003cfit[+]\u003e     \u003cfit[+]\u003e     \u003cworkfl… \u003cmodel_time […\n#\u003e 2 Ensenanza    \u003ctibble [193 ×… \u003cfit[+]\u003e     \u003cfit[+]\u003e     \u003cworkfl… \u003cmodel_time […\n#\u003e 3 Administrac… \u003ctibble [193 ×… \u003cfit[+]\u003e     \u003cfit[+]\u003e     \u003cworkfl… \u003cmodel_time […\n#\u003e # … with 1 more variable: calibration \u003clist\u003e\n#\u003e \n#\u003e $models_accuracy\n#\u003e # A tibble: 9 x 10\n#\u003e   name_serie  .model_id .model_desc  .type   mae  mape   mase smape  rmse    rsq\n#\u003e   \u003cchr\u003e           \u003cint\u003e \u003cchr\u003e        \u003cchr\u003e \u003cdbl\u003e \u003cdbl\u003e  \u003cdbl\u003e \u003cdbl\u003e \u003cdbl\u003e  \u003cdbl\u003e\n#\u003e 1 Comercio            1 ARIMA(0,1,1… Test   8.54  5.55  0.656  5.69 10.7  0.588 \n#\u003e 2 Comercio            2 SEASONAL DE… Test   9.33  6.28  0.717  6.24 11.2  0.415 \n#\u003e 3 Comercio            3 NNAR(1,1,10… Test   9.71  6.36  0.746  6.52 11.5  0.510 \n#\u003e 4 Ensenanza           1 ARIMA(1,1,1… Test   5.38  3.35  3.90   3.28  6.00 0.730 \n#\u003e 5 Ensenanza           2 SEASONAL DE… Test   5.56  3.46  4.03   3.38  6.21 0.726 \n#\u003e 6 Ensenanza           3 NNAR(1,1,10… Test   2.73  1.70  1.98   1.69  3.05 0.874 \n#\u003e 7 Administra…         1 ARIMA(0,1,1… Test   6.10  3.96 12.6    3.86  7.05 0.0384\n#\u003e 8 Administra…         2 SEASONAL DE… Test   6.45  4.19 13.4    4.07  7.61 0.0480\n#\u003e 9 Administra…         3 NNAR(1,1,10… Test   6.26  4.07 13.0    3.97  6.88 0.0524\n```\n\n### modeltime\\_multiforecast()\n\n``` r\nforecast_emae \u003c- modeltime_multiforecast(\n  model_table_emae$table_time,\n  .prop = 0.8\n)\n```\n\n``` r\nforecast_emae %\u003e% \n  select(sector, nested_forecast) %\u003e% \n  unnest(nested_forecast) %\u003e% \n  group_by(sector) %\u003e% \n  plot_modeltime_forecast(\n    .legend_max_width = 12,\n    .facet_ncol = 2, \n    .line_size = 0.5,\n    .interactive = FALSE,\n    .facet_scales = 'free_y',\n    .title='Forecasting test') \n```\n\n\u003cimg src=\"man/figures/README-unnamed-chunk-10-1.png\" width=\"100%\" /\u003e\n\n### modeltime\\_multibestmodel()\n\n``` r\nbest_model_emae \u003c- modeltime_multibestmodel(\n    .table = model_table_emae$table_time,\n    .metric = \"rmse\",\n    .minimize = TRUE,\n    .forecast = FALSE\n  )\n\nbest_model_emae\n#\u003e # A tibble: 3 x 8\n#\u003e   sector       nested_column   m_auto_arima m_stlm_arima m_nnetar nested_model  \n#\u003e   \u003cchr\u003e        \u003clist\u003e          \u003clist\u003e       \u003clist\u003e       \u003clist\u003e   \u003clist\u003e        \n#\u003e 1 Comercio     \u003ctibble [193 ×… \u003cfit[+]\u003e     \u003cfit[+]\u003e     \u003cworkfl… \u003cmodel_time […\n#\u003e 2 Ensenanza    \u003ctibble [193 ×… \u003cfit[+]\u003e     \u003cfit[+]\u003e     \u003cworkfl… \u003cmodel_time […\n#\u003e 3 Administrac… \u003ctibble [193 ×… \u003cfit[+]\u003e     \u003cfit[+]\u003e     \u003cworkfl… \u003cmodel_time […\n#\u003e # … with 2 more variables: calibration \u003clist\u003e, best_model \u003clist\u003e\n```\n\n### modeltime\\_multirefit()\n\n``` r\nmodel_refit_emae \u003c- modeltime_multirefit(models_table = best_model_emae)\n#\u003e frequency = 12 observations per 1 year\n#\u003e frequency = 12 observations per 1 year\n#\u003e frequency = 12 observations per 1 year\n\nmodel_refit_emae\n#\u003e # A tibble: 3 x 8\n#\u003e   sector       nested_column   m_auto_arima m_stlm_arima m_nnetar nested_model  \n#\u003e   \u003cchr\u003e        \u003clist\u003e          \u003clist\u003e       \u003clist\u003e       \u003clist\u003e   \u003clist\u003e        \n#\u003e 1 Comercio     \u003ctibble [193 ×… \u003cfit[+]\u003e     \u003cfit[+]\u003e     \u003cworkfl… \u003cmodel_time […\n#\u003e 2 Ensenanza    \u003ctibble [193 ×… \u003cfit[+]\u003e     \u003cfit[+]\u003e     \u003cworkfl… \u003cmodel_time […\n#\u003e 3 Administrac… \u003ctibble [193 ×… \u003cfit[+]\u003e     \u003cfit[+]\u003e     \u003cworkfl… \u003cmodel_time […\n#\u003e # … with 2 more variables: calibration \u003clist\u003e, best_model \u003clist\u003e\n```\n\n``` r\nforecast_emae \u003c- modeltime_multiforecast(\n    model_refit_emae,\n    .prop = 0.8,\n    .h = \"1 years\"\n)\n```\n\n``` r\nforecast_emae %\u003e% \n  select(sector, nested_forecast) %\u003e% \n  unnest(nested_forecast) %\u003e% \n  group_by(sector) %\u003e% \n  plot_modeltime_forecast(\n    .legend_max_width = 12,\n    .facet_ncol = 2, \n    .line_size = 0.5,\n    .interactive = FALSE,\n    .facet_scales = 'free_y',\n    .title='Forecasting'\n    ) \n```\n\n\u003cimg src=\"man/figures/README-unnamed-chunk-14-1.png\" width=\"100%\" /\u003e\n\n## Others functions :cyclone:\n\n### 🔹 Function multieval()\n\nFor a set of predictions from different models, it allows you to\nevaluate multiple metrics and return the results in a tabular format\nthat makes it easy to compare the predictions.\n\n``` r\nlibrary(yardstick)\nlibrary(erer)\n\nset.seed(123)\npredictions =\n  data.frame(truth = runif(100),\n             predict_model_1 = rnorm(100, mean = 1,sd =2),\n             predict_model_2 = rnorm(100, mean = 0,sd =2))\n\ntibble(predictions)\n#\u003e # A tibble: 100 x 3\n#\u003e     truth predict_model_1 predict_model_2\n#\u003e     \u003cdbl\u003e           \u003cdbl\u003e           \u003cdbl\u003e\n#\u003e  1 0.288            1.51            1.58 \n#\u003e  2 0.788            0.943           1.54 \n#\u003e  3 0.409            0.914           0.664\n#\u003e  4 0.883            3.74           -2.02 \n#\u003e  5 0.940            0.548          -0.239\n#\u003e  6 0.0456           4.03           -0.561\n#\u003e  7 0.528           -2.10            1.13 \n#\u003e  8 0.892            2.17           -0.745\n#\u003e  9 0.551            1.25            1.95 \n#\u003e 10 0.457            1.43           -0.749\n#\u003e # … with 90 more rows\n```\n\n``` r\nmultieval(.dataset = predictions,\n          .observed = \"truth\",\n          .predictions = c(\"predict_model_1\",\"predict_model_2\"),\n          .metrics = listn(rmse, rsq, mae))\n#\u003e $summary_table\n#\u003e # A tibble: 2 x 4\n#\u003e   modelo           rmse      rsq   mae\n#\u003e   \u003cchr\u003e           \u003cdbl\u003e    \u003cdbl\u003e \u003cdbl\u003e\n#\u003e 1 predict_model_1  1.99 0.000704  1.59\n#\u003e 2 predict_model_2  1.95 0.00115   1.61\n```\n\n### 🔹 Function insert\\_na()\n\nThis function allows adding NA values to a data frame, being able to\nselect the columns and the proportion of NAs desired.\n\n``` r\ninsert_na(.dataset = iris, columns = c(\"Sepal.Length\",\"Petal.Length\"), .p = 0.25)\n#\u003e # A tibble: 150 x 5\n#\u003e    Sepal.Width Petal.Width Species Sepal.Length Petal.Length\n#\u003e          \u003cdbl\u003e       \u003cdbl\u003e \u003cfct\u003e          \u003cdbl\u003e        \u003cdbl\u003e\n#\u003e  1         3.5         0.2 setosa           5.1         NA  \n#\u003e  2         3           0.2 setosa          NA            1.4\n#\u003e  3         3.2         0.2 setosa           4.7          1.3\n#\u003e  4         3.1         0.2 setosa          NA            1.5\n#\u003e  5         3.6         0.2 setosa          NA            1.4\n#\u003e  6         3.9         0.4 setosa           5.4          1.7\n#\u003e  7         3.4         0.3 setosa           4.6          1.4\n#\u003e  8         3.4         0.2 setosa          NA            1.5\n#\u003e  9         2.9         0.2 setosa           4.4          1.4\n#\u003e 10         3.1         0.1 setosa           4.9          1.5\n#\u003e # … with 140 more rows\n```\n\n## Website\n\n[sknifedatar website](https://rafzamb.github.io/sknifedatar/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafzamb%2Fsknifedatar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafzamb%2Fsknifedatar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafzamb%2Fsknifedatar/lists"}