The function odm_read can be used to get data from ODM database. ODMselect returns a data frame containing the required columns for working with ODM data.

odm_read(utc_offset = -5, site_id = NULL, variable_id = NULL,
  qualifier_id = NULL, method_id = NULL, source_id = NULL,
  level_id = NULL, aggregate_by = "day", FUN = "mean",
  start_date = NULL, end_date = NULL, n = 1e+06, channel = ODM)

Arguments

utc_offset

of the observation

site_id

index value for the location at which the observation was made

variable_id

index value for the variable that the data represents

qualifier_id

of the observations you want to extract

method_id

index value for the method used to collect the observation

source_id

the source of the data

level_id

the level of quality control processing

aggregate_by

aggregation level to include in SQL query. Either hour, day, month, year or none

FUN

function to aggregate by. Either min, max, mean, or sum

start_date

access data from this date forward

end_date

access data up to this date

n

maximum number of observations to return

channel

connection handle as returned by odbcConnect

Value

A data frame

Details

A standard SQL query is issued to the ODM database and the values are returned. The data returned can be limited by a start and/or end date defined by the user. Smaller datasets can speed up the workflow especially when visualising data.

Examples

if (FALSE) { # Establish connection with database ODM <- odbc::dbConnect(odbc::odbc(), dsn = "ODM", database = "OD", UID = "update", PWD = rstudioapi::askForPassword("Database password"), Port = 1433) # Extract data by site, variable, method and QC level. Clear and consistent # method to extract data. Data <- odm_read(site_id = 1, variable_id = 1, method_id = 9, level_id = 0, start_date = "2013-06-01", end_date = "2013-07-01", channel = ODM) }