R/insert-time-series-results.R
db_insert_results_ts.Rd
Insert time series data values to ODM2 database
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, ...)
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 |
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 |
true if successful
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), "
Other insert data functions: db_insert_results_m
,
db_insert_results_samples_profile
,
db_insert_results_samples
#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")