db_insert_results_ts: Insert time series data values to ODM2 database

Description Usage Arguments Details Value See Also Examples

View source: R/insert-time-series-results.R

Description

Insert time series data values to ODM2 database

Usage

1
2
3
4
5
db_insert_results_ts(db, datavalues, methodcode,
  methodtypecv = "instrumentDeployment", site_code, variables,
  sampledmedium, processinglevel = "Raw data", actionby = NULL,
  equipment_name = NULL, aggregationstatisticcv = NULL,
  zlocation = NULL, zlocationunits = NULL, ...)

Arguments

db

database connection

datavalues

data frame with columns "Timestamp" with POSIXct YYYY-MM-DD H:M:S format, and column names corresponding to variable names

methodcode

code for method used to collect data

methodtypecv

Instrument deployment or derivation

site_code

sampling feature code at which data were collected

variables

a named list of lists defining variable names, units, and columns in datavalues data frame. Create with make_vars_list or see Details.

sampledmedium

term from controlled vocabulary for medium sampled eg. air or soil

processinglevel

code for processing level. will be added to processinglevels table if new. defaults to "Raw data'.

actionby

(optional) the person who performed the action

equipment_name

(optional) the equipment used to collect the data

aggregationstatisticcv

controlled vocabulary, defaults to unknown

zlocation

(optional) z location offset

zlocationunits

(optional but required if zlocation is set) name of units of z location offset

...

parameters to pass to various db_describe_ functions

Details

Timezone: The values in the "Timestamp" column must have time in the format YYYY-MM-DD HH:MM:SS, but they can be character data or POSIXct. If they are character data, the time zone will be your computer's local time, i.e. whatever is returned from Sys.time(). To specify a different time zone, such as if you are uploading data that was collected before or after daylight savings time or you are using UTC, make sure that the dates in the Timestamp column are of POSIXct format with a timezone specified. You can check the timezone of an object using the function lubridate::tz(). In the database, datetime values are stored in one column and timezones are stored in a separate column (as "UTC offset"). In the upload function, the UTC offset is an intger determined by using format(as.POSIXct(x), "

Value

true if successful

See Also

Other insert data functions: db_insert_results_m, db_insert_results_samples_profile, db_insert_results_samples

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#db <- rodm2::create_sqlite(connect = TRUE)

#tsrv <-data.frame(
 # Timestamp = c("2018-06-27 13:45:00", "2018-06-27 13:55:00"),
  #"wd" = c(180,170),
 # "ws" = c(1, 1.5),
 # "gustspeed" = c(2, 2.5))

#db_insert_results_ts(
 # db = db,
 # datavalues = tsrv,
 # method = "SonicAnemometer",
 # site_code = "BB2",
 #  variables = list("Wind direction" = list("wd", "Degree"),
 #                   "Wind speed" = list("ws", "Meter per Second"),
 #                    "Wind gust speed" = list("gustspeed", "Meter per Second")),
 # sampledmedium = "Air")

khondula/rodm2 documentation built on Jan. 9, 2020, 1:48 p.m.