diff --git a/vignettes/sc_table_saved.Rmd b/vignettes/sc_table_saved.Rmd index 7b71e989..77fd6465 100644 --- a/vignettes/sc_table_saved.Rmd +++ b/vignettes/sc_table_saved.Rmd @@ -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 @@ -41,19 +41,19 @@ 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 @@ -61,13 +61,13 @@ my_response <- sc_table("wine.json") 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") ``` diff --git a/wine.json b/wine.json new file mode 100644 index 00000000..73a98f1d --- /dev/null +++ b/wine.json @@ -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" + ] + ] +}