Reads, aggregates, and processes the SQLite database
(data/geelite.db).
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
)[mandatory] (character) Path to the root directory of the generated database.
[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").
[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.
[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.
[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.
[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.
# 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