Skip to contents

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: 5 × 2
  label           id                                            
  <chr>           <chr>                                         
1 Bier auf Wein   str:table:4520fba3-dffd-4f2a-9cd1-d46d710b6da4
2 hierarchical    str:table:1529fb5c-8f71-425c-bc95-a017f6534c8f
3 neu             str:table:4d55ca7c-e999-49e4-90f4-396163195da5
4 lebenserwartung str:table:b0f4779b-546e-4a6c-88a1-43038cdeaf7b
5 test123         str:table:9ba81454-32f5-4ab7-b904-c446940946f5

Subsequently the id of a saved table can be used to import the table into R.

wine <- sc_table_saved("str:table:4520fba3-dffd-4f2a-9cd1-d46d710b6da4")
wine
#> Wine production as of 1970
#> 
#> Database: deweinernte (STATcube)
#> Measures: Production in hectolitres, Area in hectares
#> Fields: Year <52>, Wine colour <3>
#> 
#> Request: [2022-09-05 17:01:45]
#> STATcubeR: 0.5.0.1

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.

wine$json$write("wine.json")

The generated json file contains an API request that can be used in sc_table().

my_response <- sc_table("wine.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: [2022-09-16 08:56:40]
#> STATcubeR: 0.5.0.1

All available default tables as well as other saved tables can be discovered using sc_schema_catalogue(). See the schema article for more details.

# A data frame: 647 × 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_dewatlas1               Standardtabelle / Default tab…
 8 str:table:defaulttable_dewatlas2               Standardtabelle / Default tab…
 9 str:table:defaulttable_dewatlas3               Standardtabelle / Default tab…
10 str:table:defaulttable_dewatlas4               Standardtabelle / Default tab…
# … with 637 more rows