R/insert-sample-profile-results.R
db_insert_results_samples_profile.RdInsert sample result data values to ODM2 database
db_insert_results_samples_profile(db, datavalues, field_method = NULL, lab_method = NULL, lab_method_col = NULL, 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_col = NULL, zinterval_col = NULL, zlocationunits, ...)
| 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. only use if lab_method_col is NULL |
| lab_method_col | specify the column name of the lab method. only use if lab method is NULL |
| 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 |
| 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_col | specify column name of the zlocation |
| zinterval_col | specify column name of the z aggregation interval |
| zlocationunits | name of units of z location offset FROM CONTROLLED VOCAB |
| ... | parameters to pass to various db_describe_ functions |
true if successful
Other insert data functions: db_insert_results_m,
db_insert_results_samples,
db_insert_results_ts
# 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") # }