sc_schema | R Documentation |
Invoke the /schema endpoint of the STATcube REST API. This endpoint can be used to get all available databases and tables as well as metadata about specific databases.
The main function sc_schema()
can be used with any resource id.
sc_schema_catalogue()
and sc_schema_db()
are very simple
wrapper functions around sc_schema()
and are comparable to the
catalogue explorer or the
table view of the STATcube GUI.
The responses of the API are tree-like data structures which
are wrapped into a class called sc_schema
to simplify the usage in R.
sc_schema(id = NULL, depth = NULL, language = NULL, key = NULL, server = "ext")
## S3 method for class 'sc_schema'
print(x, tree = NULL, ..., limit = 30)
sc_schema_flatten(x, type)
sc_schema_catalogue(depth = "folder", ...)
sc_schema_db(id, depth = "valueset", language = c("en", "de"), key = NULL)
id |
A resource identifier in uid format. In case of |
depth |
If provided, the request will recurse into the given level.
For datasets, available options are |
language |
The language to be used for labeling. |
key |
( |
server |
A STATcube API server. Defaults to the external Server via
|
x |
an object of class |
tree |
whether to use the |
limit , ... |
passed to |
type |
a schema type such as "DATABASE", "VALUE" or "TABLE". See the API reference for a list of all schema types. |
for sc_schema()
and sc_schema_db()
: an object of class sc_schema
for sc_schema_flatten()
: a data.frame
for sc_schema_catalogue()
: a list
sc_schema_flatten()
: turns a sc_schema
object into a data.frame
sc_schema_catalogue()
: is similar to the
catalogue explorer of the STATcube GUI and returns
a tree-type object containing all databases and tables.
sc_schema_db()
: is similar to the
table view
of the STATcube GUI and gives information about all measures and
classification fields for a specific database
limit
and ...
will simply be ignored if tree
is set to FALSE
, which is
the default. The printing via data.tree
can take longer than the default
implementation because x
will need to be converted into a data.tree
node.
To use data.tree
printing permanently, use
options(STATcubeR.print_tree = TRUE)
my_catalogue <- sc_schema_catalogue()
## print
my_catalogue
## access the parsed catalogue
my_catalogue$Statistics$`Labour Market`
my_catalogue$Statistics$`Labour Market`$`Working hours (Labour Force Survey)`
db_schema <- sc_schema_db("deake005")
# printing
db_schema
# access child nodes
db_schema$`Demographic Characteristics`
db_schema$`Demographic Characteristics`$Gender$Gender
db_schema$`Demographic Characteristics`$Gender$Gender$male
# access the raw response from httr::GET()
my_response <- attr(db_schema, "response")
my_response$headers$date
my_content <- httr::content(my_response)
my_content$label
# print with data.tree
treeX_B1 <- sc_schema("str:group:deake005:X_B1", depth = "valueset")
print(treeX_B1, tree = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.