source("R/setup.R")$value
if (!sc_key_exists())
  knitr::opts_chunk$set(eval = FALSE)

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().

sc_table_saved_list()

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 r 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')

All available default tables as well as other saved tables can be discovered using sc_schema_catalogue(). See the r ticle("sc_schema") for more details.

sc_schema_catalogue() %>% 
  sc_schema_flatten("TABLE")


statistikat/STATcubeR documentation built on Dec. 3, 2024, 8:04 p.m.