{"id":31956676,"url":"https://github.com/petrbouchal/statnipokladna","last_synced_at":"2025-10-14T14:52:47.155Z","repository":{"id":40769413,"uuid":"216420119","full_name":"petrbouchal/statnipokladna","owner":"petrbouchal","description":"R package to use data from the Czech public finance database","archived":false,"fork":false,"pushed_at":"2025-10-06T20:27:46.000Z","size":2478,"stargazers_count":10,"open_issues_count":39,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-12T22:57:08.642Z","etag":null,"topics":["budgeting","cities","czech-republic","government","open-data","public-finance","r","rstats","rstats-package"],"latest_commit_sha":null,"homepage":"https://petrbouchal.xyz/statnipokladna/","language":"HTML","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/petrbouchal.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-10-20T20:03:29.000Z","updated_at":"2025-10-06T20:09:36.000Z","dependencies_parsed_at":"2024-03-12T18:29:49.085Z","dependency_job_id":"573f2500-caf6-4a50-b8cb-6548d0933266","html_url":"https://github.com/petrbouchal/statnipokladna","commit_stats":{"total_commits":446,"total_committers":2,"mean_commits":223.0,"dds":"0.0022421524663677195","last_synced_commit":"d81f8d48c32af252703b4b14c9175c18a6025576"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/petrbouchal/statnipokladna","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrbouchal%2Fstatnipokladna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrbouchal%2Fstatnipokladna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrbouchal%2Fstatnipokladna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrbouchal%2Fstatnipokladna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petrbouchal","download_url":"https://codeload.github.com/petrbouchal/statnipokladna/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petrbouchal%2Fstatnipokladna/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279019140,"owners_count":26086685,"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","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["budgeting","cities","czech-republic","government","open-data","public-finance","r","rstats","rstats-package"],"created_at":"2025-10-14T14:52:40.453Z","updated_at":"2025-10-14T14:52:47.138Z","avatar_url":"https://github.com/petrbouchal.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# statnipokladna \u003cimg src='man/figures/logo.png' align=\"right\" height=\"138\" /\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/statnipokladna)](https://CRAN.R-project.org/package=statnipokladna)\n[![CRAN downloads](https://cranlogs.r-pkg.org/badges/grand-total/statnipokladna)](https://CRAN.R-project.org/package=statnipokladna)\n[![CRAN monthly downloads](https://cranlogs.r-pkg.org/badges/last-month/statnipokladna)](https://CRAN.R-project.org/package=statnipokladna)\n[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n[![R-CMD-check](https://github.com/petrbouchal/statnipokladna/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/petrbouchal/statnipokladna/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\nThe goal of statnipokladna is to provide programmatic access to open data from the Státní pokladna system. Státní pokladna is a comprehensive budgeting, reporting and accounting system for Czech public organisations. This package provides user-friendly ways to access the open data from that system available at \u003chttps://monitor.statnipokladna.gov.cz\u003e. The vignettes in the package also provide an introduction to the underlying data.\n\n## Installation\n\nYou can install the released version from CRAN:\n\n``` r\ninstall.packages(\"statnipokladna\")\n```\n\n\nYou can install the current development release of statnipokladna from\n[GitHub](https://github.com/petrbouchal/statnipokladna) with:\n\n``` r\nremotes::install_github(\"petrbouchal/statnipokladna\",\n                        build_vignettes = TRUE,\n                        ref = github_release())\n```\n\nor the latest in-development version with\n\n``` r\nremotes::install_github(\"petrbouchal/statnipokladna\",\n                         build_vignettes = TRUE)\n```\n\nI also keep binaries in a `drat` repo, which you can access by\n\n``` r\ninstall.packages(\"statnipokladna\", repos = \"https://petrbouchal.xyz/drat\")\n```\n\n## Bug reports\n\nPlease report bugs at https://github.com/petrbouchal/statnipokladna/issues.\n\n## What this package enables you to do:\n\n- get cleaned-up, ready to analyse data frames based on open data dumps from the public finance database \n  - the package draws on the online data and returns a clean data frame\n  - the resulting data is ready to merge into time series\n  - time series is built based on user input\n- do this through a consistent API which supplements some of the documentation that is missing from the official endpoints (*still subject to some change*)\n- access registers published alongside the data (e.g. lists of public organisations with their identifiers and metadata), some of which can be useful in other contexts\n- augment the core data with the desired type of register\n\nSee the [Get started](https://petrbouchal.xyz/statnipokladna/articles/statnipokladna.html) vignette for background on the underlying data.\n\nSee also [Background information] below.\n\n## How does this compare to the [official analytical interface](https://monitor.statnipokladna.gov.cz/)?\n\n- no limit on the number of data points\n- no limits on the number of organisations, unlike the official interface which forces you to use a filter on some tables\n- different reports (local gov, central gov...) in one place in consistent form\n- much faster for analysis (the current version of the online interface takes long to render)\n- reproducible!!! While the online interface provides a permanent link to your analysis, this must be copied manually and does not necessarily provide an easily legible overview of how the analysis was produced (filters, columns etc.)\n- no need for the web =\u003e excel =\u003e R dance\n- drawback: for some reports, the data is published in different forms for different time periods (pre- and post-2015)\n- drawback: consolidation must be done manually\n\n### Future development\n\nthe official system has been partially overhauled in February 2020 and I am trying to find out about which parts of its new API will remain stable and can be used externally. Depending on the result, some functionality in this package can be streamlined and some can be added - e.g. \n\n- listing of available releases\n- checking against existing releases and data sets\n- retrieving some previously unpublished data e.g. calculated indicators and budget responsibility monitoring\n\n## Getting started\n\n```{r message=FALSE, warning=FALSE}\nlibrary(statnipokladna)\n```\n\nGet data from a particular part (file) of a dataset (\"výkaz\"):\n\n```{r}\nlocal_budgets \u003c- sp_get_table(table_id = \"budget-local\", # table ID, see `sp_tables`\n                           year = 2019,\n                           month = 9)\n```\n\nThe data is automatically downloaded to a temp directory, so it will be reused by future calls to `sp_get_table()` made in the same session, unless you set `force_redownload = TRUE`. You set the `dest_dir` parameter e.g. to `\".\"`, a directory will be created in your current working directory and the data will be downloaded into it so that it can persist across sessions. \n\nIt is a rather raw-looking data frame...\n\n```{r}\nhead(local_budgets)\n```\n\nbut it has been cleaned up, and can be enriched with any of the metadata codelists:\n\n```{r}\nfunctional_categories \u003c- sp_get_codelist(\"paragraf\")\n```\n\n```{r}\nfunctional_categories\n```\n\nThis contains all codes for this codelist, some of which are not valid for the time period of our core data. The function `add_codelist()` resolves this automatically.\n\nAs you can see below, you can \n\n- add multiple codelists in one pipe\n- add a codelist without downloading it first - just pass its ID to the function as a character instead of an object.\n\nCodelists are also cached, but you have one in your namespace, you can pass it as an object, provided that it has the right columns.\n\n```{r}\nlocal_budgets %\u003e% \n  sp_add_codelist(functional_categories) %\u003e% \n  sp_add_codelist(\"polozka\")\n```\n\nDownload a whole \"výkaz\" (dataset/data dump):\n\n```{r}\nsp_get_dataset(\"finm\", year = 2019) # dataset ID, see `sp_datasets`\n```\n\nThis will put the files in a temp directory.\n\nThen look at its documentation:\n\n```{r}\nstatnipokladna::sp_get_dataset_doc(\"finm\")\n```\n\nYou can get details of all the available tables in the `sp_tables` data frame; for datasets, see `sp_datasets`.\n\n## Workflows and reproducibility\n\nThe above examples present a simple all-in-one workflow, which is concise but can be too opaque when transparency and reproducibility matter. \nIt is primarity aimed at workflows which prioritise updating data: every time the script is run, data is redownloaded, unless cached via the `dest_dir` parameter.\n\nIn other situations, the priority might be to keep track of individual source files as they are downloaded from the data provider, or checking for changes at the data provider and keeping track of individual URLs from which the data was downloaded.\nFor these situations, a workflow composed of lower-level functions is available, offering finer control of the steps. See the [workflow](https://petrbouchal.xyz/statnipokladna/articles/workflow.html) vignette (`vignette(\"workflow\", package = \"statnipokladna\")`).\n\n\n\n\n## Background information\n\nNote that while the package provides a bridge from complicated data dumps to a clean data structure, you still need quite a bit of domain knowledge to be able analyse the data safely.\n\nSee the [\"How the data works\"](https://petrbouchal.xyz/statnipokladna/articles/how-the-data-works-cz.html) vignette (in Czech only, the terminology is impossible to translate) for an overview of the structure of the data on which this package draws. This also contains some notes useful for interpreting the data.\n\nA subset of this information is in the [Get started](https://petrbouchal.xyz/statnipokladna/articles/statnipokladna.html) vignette.\n\nThere is also a log of various data gotchas I discovered, also in Czech only, stored in the [data issues vignette](https://petrbouchal.xyz/statnipokladna/articles/data-issues-cz.html).\n\nA basic glossary of some of the terms used in the data sets is at \u003chttps://monitor.statnipokladna.gov.cz/metodika/\u003e.\n\n### Note\n\nNot created or endorsed by the Czech Ministry of Finance, who produce the data - but they definitely deserve credit for releasing the data and maintaining the application.\n\n## See also\n\n### R Packages\n\n- [CzechData](https://jancaha.github.io/CzechData/) by @JanCaha for (mainly) geospatial data about the Czech Republic (both admin. boundaries and topology and geography)\n- [RCzechia](https://cran.r-project.org/package=RCzechia) for another approach to Czech geospatial data and access to the official public geocoder and reverse geocoder\n- [czso](https://github.com/petrbouchal/czso) for access to Czech statistical open data\n- [eurostat](https://cran.r-project.org/package=eurostat) for access to Eurostat data\n- [OECD](https://cran.r-project.org/package=OECD) for access to OECD data, incl. a large amount of financial and economic data\n\n\n### Other Czech public data\n\n- [National Open Data Catalogue](https://data.gov.cz/)\n- [KNOD](https://github.com/kokes/knod) by Ondřej Kokeš for an overview of public data\n- [Hlídač státu](https://www.hlidacstatu.cz/) by @michalblaha for easy (web and API) access to a large suite of transparency-focused datasets and their integration (public disclosures of contracts, tenders, political contributions...)\n- CEDR (Centrální registr dotací) for a database of public subsidies, incl. to public bodies\n\n## Acknowledgments\n\nThanks to @smallhillcz and the Státní pokladna/Monitor developers and maintainers for responding to queries and generally keeping the thing running.\n\n## Contributing\n\nSee [CONTRIBUTING.md](https://github.com/petrbouchal/statnipokladna/blob/master/.github/CONTRIBUTING.md) for a guide on how to contribute to the project.\n\nPlease note that the 'statnipokladna' project is released with a\n[Contributor Code of Conduct](https://petrbouchal.xyz/statnipokladna/CODE_OF_CONDUCT.html).\nBy contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetrbouchal%2Fstatnipokladna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetrbouchal%2Fstatnipokladna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetrbouchal%2Fstatnipokladna/lists"}