This is a suggestion that can be completely ignored ...
I noticed that there is duplicated code that converts ASCII to hex in the pull_*() functions. For example, in pull_catch()https://github.com/pfmc-assessments/nwfscSurvey/blob/d371e6f4f6474ff436c53b02c8f6cafa3f76ba7d/R/pull_catch.R#L119-L129
I think we should create a helper function, e.g., see below, because I could not find an existing function that does what we need, though I am sure that there is one somewhere in cyberland.
convert_to_hex_string <- function(x) {
hex_comma <- toupper(paste0("%", charToRaw(",")))
hex_quote <- paste0("%", charToRaw('"'))
hex_space <- paste0("%", charToRaw(" "))
stopifnot(inherits(x, "character"))
# Convert spaces to %20
x_no_spaces <- gsub(pattern = " ", replacement = hex_space, x)
# Wrap each string in quotes with %22 and
# separate strings with %2C, which is a comma
out <- paste0(hex_quote, x_no_spaces, hex_quote, collapse = hex_comma)
return(out)
}
The following example uses the above code and ends up with the same result as what is currently in the code:
This is a suggestion that can be completely ignored ... I noticed that there is duplicated code that converts ASCII to hex in the
pull_*()
functions. For example, inpull_catch()
https://github.com/pfmc-assessments/nwfscSurvey/blob/d371e6f4f6474ff436c53b02c8f6cafa3f76ba7d/R/pull_catch.R#L119-L129 I think we should create a helper function, e.g., see below, because I could not find an existing function that does what we need, though I am sure that there is one somewhere in cyberland.The following example uses the above code and ends up with the same result as what is currently in the code: