db_insert_results_samples: Insert sample result data values to ODM2 database

Description Usage Arguments Value See Also Examples

View source: R/insert-sample-results.R

Description

Insert sample result data values to ODM2 database

Usage

1
2
3
4
5
6
7
db_insert_results_samples(db, datavalues, field_method = NULL,
  lab_method, variables, sampledmedium, site_code_col = "Site",
  sample_code_col = "Sample", processinglevel = "Raw data",
  aggregationstatistic = "Unknown", time_aggregation_interval = list(1,
  "Minute"), field_actionby = NULL, field_equipment_name = NULL,
  lab_actionby = NULL, lab_equipment_name = NULL, zlocation = NULL,
  zlocationunits = NULL, ...)

Arguments

db

database connection

datavalues

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

field_method

short description of field method to collect new samples. Dont include for new data about existing samples.

lab_method

short description of lab method

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

site_code_col

name of column with site codes. defaults to "Site"

sample_code_col

name of column in input data frame with sample ID. defeaults to "Sample"

processinglevel

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

aggregationstatistic

controlled vocabulary, defaults to unknown

time_aggregation_interval

defaults to unknown

field_actionby

optional first name of lead for field action, must already be in people table

field_equipment_name

optional code name of equipment used for field action, must already be in equipment table

lab_actionby

optional first name of lead for lab action, must already be in people table

lab_equipment_name

optional code name of equipment used for lab action, must already be in equipment table

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

Value

true if successful

See Also

Other insert data functions: db_insert_results_m, db_insert_results_samples_profile, db_insert_results_ts

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# make database and data frame
db <- rodm2::create_sqlite(connect = TRUE)
mrv <- data.frame(Timestamp = "2018-06-27 13:55:00",
"pH" = 4.5, Site = "BB2", Sample = "CEM 1", stringsAsFactors = FALSE)

db_insert_results_sample(db = db, datavalues = soil_ph,
    field_method = "1 inch 30 cm soil core",
    lab_method = "Soil pH CEM",
    variables = list("pH" = list(column = "pH", units = "pH")),
    sampledmedium = "Soil")

## End(Not run)

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