This helper function retrieves data of all periods from the given database by using the given query and adding in the period dependent parameters. Reason for this function is to avoid repetition in the load functions.

query_database(
  database,
  query,
  selection = "",
  add_fields = "",
  conjunction = "",
  n_periods = 3
)

Arguments

database

name of fieldmap/access database (with specific fieldmap structure) including path

query

query that is adapted to be used in different periods, in which the following parameters can be used:

  • `%1$d` : replaced by the period number,

  • `%2$s` : replaced by an empty string in period 1 and by '_?eSet' in all other periods (with ? the period)

  • `%3$s` : replaced by the string given in argument selection

  • `%4$s` : replaced by the string given in argument add_fields

  • `%5$s` : replaced by the string given in argument conjunction

selection

string that will be added to `%3$s` in the query

add_fields

string that will be added to `%4$s` in the query

conjunction

string that will be added to `%5$s` in the query

n_periods

highest period number that is present in the database (change default here when a new period is added to the database)

Value

Dataframe containing the result of the query and an additional column period