Skip to content

Commit

Permalink
Update NEWS and README
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhard-da committed Oct 10, 2024
1 parent 05ee0ae commit cec9437
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 31 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Upcoming (1.0.0)
# STATcubeR 1.0.0

* First Version for CRAN
* Update print methods with the `{tibble}` package (#32)
Expand Down
85 changes: 55 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,72 @@
---
editor_options:
markdown:
wrap: 72
---

# STATcubeR <img src="man/figures/logo2.svg" align="right" alt="" width="120" />
# STATcubeR <img src="man/figures/logo2.svg" align="right" width="120"/>

<!-- badges: start -->

[![R-CMD-check](https://github.com/statistikat/STATcubeR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/statistikat/STATcubeR/actions/workflows/R-CMD-check.yaml)
[![GitHub code size in
bytes](https://img.shields.io/github/languages/code-size/statistikat/STATcubeR?logo=github)](https://github.com/statistikat/STATcubeR)
[![GitHub last
commit](https://img.shields.io/github/last-commit/statistikat/STATcubeR.svg?logo=github)](https://github.com/statistikat/STATcubeR/commits/master)

<!-- badges: end -->

R client for all things [STATcube](https://statcube.at).
Get data from the STATcube REST API or via the open government data portal at
https://data.statistik.gv.at. `{STATcubeR}` makes it easy to include both those
datasources into your R projects.
R client for all things [STATcube](https://statcube.at). Get data from
the STATcube REST API or via the open government data portal at
<https://data.statistik.gv.at>. `{STATcubeR}` makes it easy to include
both those datasources into your R projects.

## Installation

This package can be installed directly from github using the `{remotes}` package.
Current versions of STATcubeR can be directly downloaded from CRAN using

``` r
install.packages("STATcubeR")
```

or directly from [github](https://github.com/statistikat/STATcubeR) using the
`{remotes}` package.

```r
``` r
remotes::install_github("statistikat/STATcubeR")
```

<details>
<summary>Alternative: Install from tar.gz archives</summary>

If you are not able to use `install_github()` to install `STATcubeR`,
you can also download the package as a tar archive from https://github.com/statistikat/STATcubeR/tags.
The package can then be installed by providing a path to the downloaded archive file.
<summary>Alternative: Install from `tar.gz` Archives</summary>

```r
install.packages('STATcubeR-0.6.0.tar.gz', repos = NULL)
If you are not able to use `remotes::nstall_github()` to install
`STATcubeR`, you can also download the package as an archive from
<https://github.com/statistikat/STATcubeR/tags>. The package can then be
installed by providing a path to the downloaded archive file, for
example:

``` r
install.packages('STATcubeR-x.y.z.tar.gz', repos = NULL)
```

</details>

## Open Data

To import datasets from https://data.statistik.gv.at, pass the dataset
id to the `od_table()` function. For example, OGD data about the [Austrian population in 2020](https://data.statistik.gv.at/web/meta.jsp?dataset=OGD_bevstandjbab2002_BevStand_2020)
To import datasets from <https://data.statistik.gv.at>, pass the dataset
id to the `od_table()` function. For example, OGD data about the
[Austrian population in
2020](https://data.statistik.gv.at/web/meta.jsp?dataset=OGD_bevstandjbab2002_BevStand_2020)
can be accessed as follows.

```r
``` r
library(STATcubeR)
population <- od_table("OGD_bevstandjbab2002_BevStand_2020")
population$tabulate()
```

```
```
# A STATcubeR tibble: 392,508 x 5
`Time section` Sex `Commune (aggregation by polit… `Age in single ye… Number
* <date> <fct> <fct> <fct> <int>
Expand All @@ -57,24 +77,28 @@ population$tabulate()
# … with 392,504 more rows
```

The resulting object contains labeled data (see above), raw data, metadata and more.
See the [OGD article](https://statistikat.github.io/STATcubeR/articles/od_table.html) for further details.
The [available datasets article](https://statistikat.github.io/STATcubeR/articles/od_list.html) provides
an overview of the 315 datasets that are compatible with `od_table()`.
The resulting object contains labeled data (see above), raw data,
metadata and more. See the [OGD
article](https://statistikat.github.io/STATcubeR/articles/od_table.html)
for further details. The [available datasets
article](https://statistikat.github.io/STATcubeR/articles/od_list.html)
provides an overview of the 315 datasets that are compatible with
`od_table()`.

## STATcube API

In order to use the REST API, it is required to set up an API key. As mentioned in the
[API key article](https://statistikat.github.io/STATcubeR/articles/sc_key.html),
In order to use the REST API, it is required to set up an API key. As
mentioned in the [API key
article](https://statistikat.github.io/STATcubeR/articles/sc_key.html),
this requires a STATcube subscription.

There are four main functions that interact with the API

- `sc_schema_catalogue()` lists all available datasets and tables
- `sc_schema_db()` provides metadata about a specific database
- `sc_table()` requests a table from the API according to a json
- `sc_schema_catalogue()` lists all available datasets and tables
- `sc_schema_db()` provides metadata about a specific database
- `sc_table()` requests a table from the API according to a json
standard
- `sc_table_saved()` requests a table based on an id
- `sc_table_saved()` requests a table based on an id

More information about the first two functions can be found in the
[schema
Expand All @@ -90,13 +114,13 @@ Both OGD data and tables form the REST API are wrapped into an `{R6}`
class to provide easy access to data and metadata. For example, the
`$tabulate()` method is also available for tables from the REST API.

```r
``` r
# https://statcube.at/statcube/openinfopage?id=debevstandjbab2002
population <- sc_table_saved("defaulttable_debevstandjbab2002")
population$tabulate()
```

```
```
# A STATcubeR tibble: 10 x 3
`Time section` `Commune (aggregation by political district)` Number
<date> <fct> <dbl>
Expand All @@ -107,5 +131,6 @@ population$tabulate()
# … with 6 more rows
```

See the [base class article](https://statistikat.github.io/STATcubeR/articles/sc_data.html)
See the [base class
article](https://statistikat.github.io/STATcubeR/articles/sc_data.html)
for more information about the features of this class.

0 comments on commit cec9437

Please sign in to comment.