/
sc_table_saved.Rmd
72 lines (52 loc) · 1.86 KB
/
sc_table_saved.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
---
title: "Load Saved Tables"
description: >
STATcube allows you to save tables in the GUI.
You can import those saved tables using `sc_table_saved()`.
This function can also be used to import default tables for databases.
link_text: "saved tables article"
---
```{r, echo = FALSE}
source("R/setup.R")$value
```
```{r, include = FALSE}
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()`.
```{r}
sc_table_saved_list()
```
Subsequently the `id` of a saved table can be used to import the table into R.
```{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.
```{r, eval = FALSE}
tab$json$write("tab.json")
```
The generated json file contains an API request that can be used in
`sc_table()`.
```{r, eval = FALSE}
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()`.
```{r}
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.
```{r}
sc_schema_catalogue() %>%
sc_schema_flatten("TABLE")
```
[saved tables]: https://docs.wingarc.com.au/superstar/9.12/superweb2/user-guide/save-and-reload-tables