From 8c5fc481a3482d5b6f93566672563ad34d636046 Mon Sep 17 00:00:00 2001 From: Bruce Delo Date: Mon, 1 Apr 2024 12:38:00 -0300 Subject: [PATCH 1/4] First slate of changes from Shannon's feedback. --- R/imos_to_otn_receivers.R | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/R/imos_to_otn_receivers.R b/R/imos_to_otn_receivers.R index 7383448..2904fe9 100644 --- a/R/imos_to_otn_receivers.R +++ b/R/imos_to_otn_receivers.R @@ -22,14 +22,16 @@ 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 @@ -42,11 +44,14 @@ imos_to_otn_receivers <- function(rcvr_dataframe) { 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") ) # Have to do a little extra manipulation on the dataframe to give "RECOVERED" From aaa62cf8a45b9a7ed4f52f60332c41ea880fbf7a Mon Sep 17 00:00:00 2001 From: Bruce Delo Date: Mon, 1 Apr 2024 13:16:46 -0300 Subject: [PATCH 2/4] A couple more fixes, plus the last of the project code/detectedby fixes from Caitlin. --- R/imos_to_otn_receivers.R | 6 +++++- R/otn_imos_column_map.R | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/R/imos_to_otn_receivers.R b/R/imos_to_otn_receivers.R index 2904fe9..0819fe1 100644 --- a/R/imos_to_otn_receivers.R +++ b/R/imos_to_otn_receivers.R @@ -34,7 +34,11 @@ imos_to_otn_receivers <- function(rcvr_dataframe) { 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, 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, From 19b3f194c14c63546049f0be1b0293af47873df3 Mon Sep 17 00:00:00 2001 From: Bruce Delo Date: Mon, 1 Apr 2024 13:50:10 -0300 Subject: [PATCH 3/4] Fixes to the date column formatting. --- R/imos_to_otn_receivers.R | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/R/imos_to_otn_receivers.R b/R/imos_to_otn_receivers.R index 0819fe1..cd7d391 100644 --- a/R/imos_to_otn_receivers.R +++ b/R/imos_to_otn_receivers.R @@ -43,7 +43,7 @@ imos_to_otn_receivers <- function(rcvr_dataframe) { 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, @@ -56,6 +56,23 @@ imos_to_otn_receivers <- function(rcvr_dataframe) { 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" From cdfb06096db0474b662dadbd918fcd918a0be6d0 Mon Sep 17 00:00:00 2001 From: jackVanish Date: Mon, 1 Apr 2024 16:51:59 +0000 Subject: [PATCH 4/4] Style code (GHA) --- R/imos_to_otn_receivers.R | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/R/imos_to_otn_receivers.R b/R/imos_to_otn_receivers.R index cd7d391..262a436 100644 --- a/R/imos_to_otn_receivers.R +++ b/R/imos_to_otn_receivers.R @@ -56,23 +56,23 @@ imos_to_otn_receivers <- function(rcvr_dataframe) { 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()) + ) + + # 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) + 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")) + across(ends_with("_DATE_TIME"), ~ stringr::str_replace(.x, " ", "T")) ) # Have to do a little extra manipulation on the dataframe to give "RECOVERED"