Learn R Programming

geeLite (version 1.0.6)

read_db: Reading, Aggregating, and Processing the SQLite Database

Description

Reads, aggregates, and processes the SQLite database (data/geelite.db).

Usage

read_db(
  path,
  variables = "all",
  freq = c("month", "day", "week", "bimonth", "quarter", "season", "halfyear", "year"),
  prep_fun = NULL,
  aggr_funs = function(x) mean(x, na.rm = TRUE),
  postp_funs = NULL
)

Arguments

path

[mandatory] (character) Path to the root directory of the generated database.

variables

[optional] (character or integer) Names or IDs of the variables to be read. Use the fetch_vars function to identify available variables and IDs (default: "all").

freq

[optional] (character or NULL) The frequency for data aggregation. Options include "day", "week", "month", "bimonth", "quarter", "season", "halfyear", "year" (default: "month"). If NULL, no aggregation is performed and native dates are returned.

prep_fun

[optional] (function or NULL) A function for pre-processing time series data after expanding to daily frequency and before aggregation. This daily expansion is performed whenever freq is not NULL. If prep_fun = NULL (default), linear interpolation (via linear_interp) is applied on the daily series. If freq = NULL, no preprocessing is performed and native dates are returned.

aggr_funs

[optional] (function or list) Aggregation function(s) used when aggregating to freq.

  • If a single function is provided, it is used for all variables.

  • If an unnamed list of functions is provided, all functions are applied to all variables (treated as default).

  • If a named list is provided, names must be variable names (as returned by fetch_vars) and/or "default"; named entries override the default for those variables.

postp_funs

[optional] (function or list or "external") Post- processing function(s) applied after aggregation.

  • If a single function or NULL is provided, it is used for all variables as default.

  • If an unnamed list of functions is provided, all are applied to all variables (treated as default).

  • If a named list is provided, names must be variable names (as returned by fetch_vars) and/or "default"; named entries override the default for those variables.

  • If "external", functions are loaded from postp/.

Default is NULL.

Examples

Run this code
# Example: Reading variables by IDs
if (FALSE) {
  db_list <- read_db(path = "path/to/db",
    variables = c(1, 3))
}

Run the code above in your browser using DataLab