odm_read: Query an ODM database

Description Usage Arguments Details Value Examples

View source: R/odm_read.R

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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

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.

Value

A data frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# 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)

## End(Not run)

D-ESC/ODMr documentation built on Sept. 16, 2021, 10:52 a.m.