Skip to content

Commit

Permalink
Fixes to the date column formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackVanish committed Apr 1, 2024
1 parent aaa62cf commit 19b3f19
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion R/imos_to_otn_receivers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"
Expand Down

0 comments on commit 19b3f19

Please sign in to comment.