Skip to content

Commit

Permalink
proper fix sc_table_saved
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkowa committed Apr 8, 2024
1 parent dbd90fb commit e2fe725
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 11 deletions.
22 changes: 11 additions & 11 deletions vignettes/sc_table_saved.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ 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,eval=FALSE}
```{r}
sc_table_saved_list()
```

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

```{r, eval = FALSE}
wine <- sc_table_saved("str:table:4520fba3-dffd-4f2a-9cd1-d46d710b6da4")
```{r}
tab <- sc_table_saved("str:table:16f39429-8a1b-4593-a129-d5c646368f0f")
```

## Keys and accounts
Expand All @@ -41,33 +41,33 @@ account. Saved tables from other accounts can not be listed or requested.
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}
wine$json$write("wine.json")
```{r}
tab$json$write("tab.json")
```

```{r, include=FALSE,eval=FALSE}
on.exit(fs::file_delete("wine.json"))
```{r, include=FALSE}
on.exit(fs::file_delete("tab.json"))
```

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

```{r,eval=FALSE}
my_response <- sc_table("wine.json")
```{r}
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,eval=FALSE}
```{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,eval=FALSE}
```{r}
sc_schema_catalogue() %>%
sc_schema_flatten("TABLE")
```
Expand Down
57 changes: 57 additions & 0 deletions wine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"database": "str:database:deerwobs17",
"measures": [
"str:statfn:deerwobs17:F-BETRIEB:F-BETRANZ:SUM",
"str:statfn:deerwobs17:F-OBST:F-FLAECHE:SUM"
],
"recodes": {
"str:field:deerwobs17:F-OBST:C-PFLOBSOR0-0": {
"map": [
[
"str:value:deerwobs17:F-OBST:C-PFLOBSOR0-0:C-PFLOBSOR1-0:PFLOBSOR1-1"
]
],
"total": false
},
"str:field:deerwobs17:F-BETRIEB:C-PFLC41-0": {
"map": [
[
"str:value:deerwobs17:F-BETRIEB:C-PFLC41-0:C-B00-0:B00-1"
],
[
"str:value:deerwobs17:F-BETRIEB:C-PFLC41-0:C-B00-0:B00-2"
],
[
"str:value:deerwobs17:F-BETRIEB:C-PFLC41-0:C-B00-0:B00-3"
],
[
"str:value:deerwobs17:F-BETRIEB:C-PFLC41-0:C-B00-0:B00-4"
],
[
"str:value:deerwobs17:F-BETRIEB:C-PFLC41-0:C-B00-0:B00-5"
],
[
"str:value:deerwobs17:F-BETRIEB:C-PFLC41-0:C-B00-0:B00-6"
],
[
"str:value:deerwobs17:F-BETRIEB:C-PFLC41-0:C-B00-0:B00-7"
],
[
"str:value:deerwobs17:F-BETRIEB:C-PFLC41-0:C-B00-0:B00-8"
],
[
"str:value:deerwobs17:F-BETRIEB:C-PFLC41-0:C-B00-0:B00-9"
]
],
"total": false
}
},
"dimensions": [
[
"str:field:deerwobs17:F-OBST:C-PFLOBSOR0-0"
],
[
"str:field:deerwobs17:F-BETRIEB:C-PFLC41-0"
]
]
}

0 comments on commit e2fe725

Please sign in to comment.