View source: R/dbpf_observations_agg.R
dbpf_observations_agg | R Documentation |
Provides mean min max and count for a certain period and one or several locations.
dbpf_observations_agg(
con,
location_name,
unit_of_measurement = "C",
period = 1,
time_b = "1950-01-01 00:00:00+00",
time_e = "2050-01-01 00:00:00+00",
verbose = FALSE,
fetch = FALSE,
n = 1e+05
)
con |
Database connection object, as returned by dbpf_con() |
location_name |
Character string or list of several with the location name(s) to be queried for. |
unit_of_measurement |
Unit of measurments, defaults to "C". Used to identify the observation time - see Details. |
period |
Period over wich to aggregate time series [h], defaults to one hour (period = 1). |
time_b |
Begin time for the interval to be analysed. Use the format "1950-01-01 00:00:00+00" |
time_e |
End time for the interval to be analysed. Use the format "1950-01-01 00:00:00+00" |
verbose |
Provide terminal output of the query string? (defaults to FALSE) |
fetch |
Whether to return results incrementally using dbSendQuery & dbFetch(), otherwise downloads them all at once using dbGetQuery(). Defaults to FALSE. |
n |
if fetch == TRUE, then specifies the number of rows to download in each batch. Ignored if fetch == FALSE. |
These simple functions return all data as data frames. When making a query many times, optimise the SQL statement to only request the data you actually need. Details of aggregation: The aggregation is based on a new column calculated based on the number of seconds elapsed since 1970-01-01 00:00:00 UTC (referred to as 'epoch'). The rounding [FLOOR(epoch/period/3600) * period * 3600] thereby references all values of a period to the time when this period begins. For example, a daily average (period = 24) will include all values between 2016-11-01 00:00:00 and 2016-11-02 23:59:59 under the timestamp 2016-11-01 00:00:00.
The unit_of_measurement variable is used to distinguish between different measurement types. The default (C) will return observations that measure temperature in degrees celsius. To obtain observations of relative humidity, use "
When performing large queries (millions of rows), it is recommended to set fetch = TRUE. Otherwise R can run into trouble.
Data frame with locations in rows and columns loc_name, height, max, min, avg, cnt
Stephan Gruber <stephan.gruber@carleton.ca>
## Not run:
con <- dbpf_con()
dbpf_observations_agg(con, "NGO-RC-163_ST01", period = 24)
dbDisconnect(con)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.