diff --git a/R/imos_to_otn_receivers.R b/R/imos_to_otn_receivers.R index 7383448..262a436 100644 --- a/R/imos_to_otn_receivers.R +++ b/R/imos_to_otn_receivers.R @@ -22,31 +22,57 @@ imos_to_otn_receivers <- function(rcvr_dataframe) { depth_below_surface, receiver_name, receiver_status, - receiver_recovery_datetime + receiver_recovery_datetime, + receiver_recovery_latitude, + receiver_recovery_longitude ) %>% mutate( BOTTOM_DEPTH = NA, RISER_LENGTH = NA, CODE_SET = NA, - AR_MODEL_NUMBER = NA, - AR_SERIAL_NUMBER = NA, + AR_MODEL_NO = NA, + AR_SERIAL_NO = NA, DATA_DOWNLOADED = NA, DOWNLOAD_DATE_TIME = NA, - COMMENTS = NA + COMMENTS = NA, + TRANSMITTER = NA, + TRANSMITTER_MODEL = NA, + DEPLOYED_BY = NA, + FILENAME = NA ) %>% rename( OTN_ARRAY = receiver_project_name, STATION_NO = station_name, - DEPLOY_DATE_TIME = receiver_deployment_datetime, + `DEPLOY_DATE_TIME (yyyy-mm-ddThh:mm:ss)` = receiver_deployment_datetime, DEPLOY_LAT = receiver_deployment_latitude, DEPLOY_LONG = receiver_deployment_longitude, INSTRUMENT_DEPTH = depth_below_surface, RECOVERED = receiver_status, - RECOVER_DATE_TIME = receiver_recovery_datetime + RECOVER_DATE_TIME = receiver_recovery_datetime, + RECOVER_LAT = receiver_recovery_latitude, + RECOVER_LONG = receiver_recovery_longitude ) %>% - separate( - col = receiver_name, - into = c("INS_MODEL_NUMBER", "INS_SERIAL_NUMBER", sep = "-") + separate_wider_delim( + cols = receiver_name, + delim = "-", + names = c("INS_MODEL_NO", "INS_SERIAL_NO") + ) + + # We have to do some cleaning up of date formats in the appropriate columns. + # First we'll hit them with Lubridate to make sure they're real dates, formatted correctly. + # Then, since they need a "T" in there, we'll cast them back to character strings and slot a 'T' + # in where once there was whitespace. Simple! I don't love calling multiple near-identical mutates, but I also + # don't like how unreadable and cursed it is to do the requisite jiggery-pokery to get multiple functions into a single + # mutate(across()) + rcvr_return <- rcvr_return %>% + mutate( + across(ends_with("_DATE_TIME"), lubridate::ymd_hms) + ) %>% + mutate( + across(ends_with("_DATE_TIME"), as.character) + ) %>% + mutate( + across(ends_with("_DATE_TIME"), ~ stringr::str_replace(.x, " ", "T")) ) # Have to do a little extra manipulation on the dataframe to give "RECOVERED" diff --git a/R/otn_imos_column_map.R b/R/otn_imos_column_map.R index 6a51e85..c5b1bca 100644 --- a/R/otn_imos_column_map.R +++ b/R/otn_imos_column_map.R @@ -94,7 +94,7 @@ otn_imos_column_map <- function(det_dataframe, rcvr_dataframe = NULL, tag_datafr WORMS_species_aphia_id = sapply(det_dataframe$scientificname, USE.NAMES = FALSE, FUN = get_aphiaid_from_lookup, lookup = lookup), animal_sex = NA, receiver_name = receiver, - receiver_project_name = receiver_group, + receiver_project_name = detectedby, transmitter_serial_number = NA, transmitter_type = NA, transmitter_sensor_type = NA,