Update Sample Field Sheet Data
update_field_sheet_samples.Rd
update_field_sheet_samples()
takes a formatted tibble of field sample
data and updates those samples in the database.
Arguments
- con
A DBI connection object obtained from DBI::dbConnect()
- field_data
the field data processed using
process_field_sheet_samples
Seecreate_field_sheet
andget_field_sheet_event_plan
for more information on creating field sheet workbooks, andprocess_field_sheet_samples
for more information on processing raw data before updating in the database.
Details
This function requires a valid connection to the database and a processed dataset
with all variables in the correct format. Errors may be due to invalid data structure or
connection; see is_valid_con
and is_valid_sample_field_data
for more
information. Variables should be as follows:
sample_id The unique identifier for the sample recorded, of class "character".
datetime_collected The date and time (YYYY-MM-DD H:M:S) the sample was processed, of class "datetime" or ("POSIXct" "POSIXt")
fork_length_mm The recorded fork length corresponding to the sample, of class "numeric".
field_run_type_id The unique identifier for the field run type, of class "numeric".
field_comment Any recorded comments from the field regarding the sample, of class "character".
See also
Other field sheet helpers:
create_field_sheet()
,
create_season_field_sheets()
,
get_field_sheet_event_plan()
,
process_field_sheet_samples()
Examples
con <- grunID::gr_db_connect()
#> ℹ refreshing Azure auth token
#> ✔ refreshing Azure auth token ... done
#>
#> Error: connection to server at "localhost" (::1), port 5432 failed: Connection refused (0x0000274D/10061)
#> Is the server running on that host and accepting TCP/IP connections?
#> connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused (0x0000274D/10061)
#> Is the server running on that host and accepting TCP/IP connections?
filepath <- "data-raw/test.xlsx"
field_data_clean <- process_field_sheet_samples(filepath)
#> Error: `path` does not exist: 'data-raw/test.xlsx'
update_field_sheet_samples(con, field_data_clean)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'dbObj' in selecting a method for function 'dbIsValid': object 'con' not found