ptt_db_update: Add and update PTT database

View source: R/update.R

ptt_db_updateR Documentation

Add and update PTT database

Description

'ptt_update_db' updates the database according to the contents of a database list.

Usage

ptt_db_update(db_list_name, tables = "all")

ptt_add_query(
  db_list_name,
  url,
  query = NULL,
  table_code = NULL,
  call = "ptt_get_statfi(url, query)"
)

ptt_remove_query(db_list_name, table_code)

Arguments

db_list_name

A database list name.

tables

A character vector of tables to update.

url

A url of table in statfin

query

A query list from pxweb_print_full_query.

table_code

A name of table to add. If NULL (default) the name is constructed from url.

call

A call to run query.

Value

A named list with update: names of updated tables and error: names of tables with an error.

Functions

  • ptt_add_query(): Add a query to the database.

  • ptt_remove_query(): Remove a query from the database.

Examples


 ptt_add_query(
   "test_db",
   "test2",
   url = "https://pxweb2.stat.fi/PxWeb/pxweb/fi/StatFin/StatFin__vkour/statfin_vkour_pxt_12bq.px/",
   query =
          list(
            "Vuosi"=c("1980"),
             "Alue"=c("SSS"),
             "Ik\U00E4"=c("SSS","15-19"),
             "Sukupuoli"=c("SSS","1","2"),
             "Koulutusaste"=c("SSS","3T8"),
             "Tiedot"=c("vaesto")),
   call = c("ptt_get_statfi(url, query)")
   )

 ptt_db_update(db_list_name = "test_db")

 test1_dat <- ptt_read_data("test2")

 ptt_add_query("test_db",
               url = "https://pxweb2.stat.fi/PxWeb/pxweb/fi/StatFin/StatFin__vkour/statfin_vkour_pxt_12bq.px/",
               query = NULL,
               call = "ptt_get_statfi_robonomist(url)")

 ptt_db_update("test_db", tables = "vkour_12bq")



pttry/pttdatahaku documentation built on Jan. 25, 2025, 10:37 a.m.