## ✔ Key could be verified via a test request
## ℹ The provided key will be available for this R session
## ℹ Add `STATCUBE_KEY_EXT = XXXX` to "~/.Renviron" to set the key
## persistently. Replace `XXXX` with your key
If saved
tables are present in STATcube, those can be imported without
downloading a json file. All saved tables can be shown with
sc_table_saved_list()
.
# A data frame: 2 × 2
label id
<chr> <chr>
1 meineErsteTabelle str:table:16f39429-8a1b-4593-a129-d5c646368f0f
2 meineZweiteTabelle str:table:e4e1b473-32c4-42b4-a67d-18169af557cc
Subsequently the id
of a saved table can be used to
import the table into R.
tab <- sc_table_saved("str:table:16f39429-8a1b-4593-a129-d5c646368f0f")
Keys and accounts
Tables are always saved to the logged in STATcube account. The API key is bound to an account and can only list the saved tables from that account. Saved tables from other accounts can not be listed or requested.
Converting saved tables to JSON requests
To make the table available for later use or for other users of STATcubeR, the response can be exported into a json.
tab$json$write("tab.json")
The generated json file contains an API request that can be used in
sc_table()
.
my_response <- sc_table("tab.json")
Default Tables
Most STATcube databases have an associated default table. Those
default tables can also be loaded with
sc_table_saved()
.
sc_table_saved('str:table:defaulttable_deake005')
#> Working hours (Labour Force Survey)
#>
#> Database: deake005 (STATcube)
#> Measures: Average hours actually worked per week, Average hours usually
#> worked per week
#> Fields: Time section <1>
#>
#> Request: [2024-11-29 09:59:16]
#> STATcubeR: 1.0.0
All available default tables as well as other saved tables can be
discovered using sc_schema_catalogue()
. See the
schema article
for more details.
sc_schema_catalogue() %>%
sc_schema_flatten("TABLE")
# A data frame: 698 × 2
id label
<chr> <chr>
1 str:table:7f851bfd-4bc0-4cc7-9013-e3c7982c9842 Monitoring
2 str:table:defaulttable_depeopleml Standardtabelle / Default tab…
3 str:table:defaulttable_dedemo Standardtabelle / Default tab…
4 str:table:E-A_nach_Bundeslaendern_dedemo E-A_nach_Bundeslaendern_dedemo
5 str:table:Jahre_nach_NUTS_dedemo Jahre_nach_NUTS_dedemo
6 str:table:defaulttable_dekonjunkturmonitor Standardtabelle / Default tab…
7 str:table:defaulttable_dewatlas13 Standardtabelle / Default tab…
8 str:table:defaulttable_dewatlas17 Standardtabelle / Default tab…
9 str:table:defaulttable_dewatlas11 Standardtabelle / Default tab…
10 str:table:defaulttable_dewatlas15 Standardtabelle / Default tab…
# ℹ 688 more rows