Skip to content

Commit

Permalink
refactor: add function to create species string #126
Browse files Browse the repository at this point in the history
  • Loading branch information
Chantel Wetzel committed Apr 4, 2024
1 parent 26f89a9 commit e949cb4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
7 changes: 1 addition & 6 deletions R/pull_bio.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,7 @@ pull_bio <- function(common_name = NULL,
)

# symbols here are generally: %22 = ", %2C = ",", %20 = " "
species_str <- paste0("%22",stringr::str_replace_all(species[1]," ","%20"),"%22")
if(length(species) > 1) {
for(i in 2:length(species)) {
species_str <- paste0(species_str, "%2C", paste0("%22",stringr::str_replace_all(species[i]," ","%20"),"%22"))
}
}
species_str <- convert_to_hex_string(species)
add_species <- paste0("field_identified_taxonomy_dim$", var_name, "|=[", species_str,"]")

if (any(species == "pull all")) {
Expand Down
7 changes: 1 addition & 6 deletions R/pull_biological_samples.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ pull_biological_samples <- function(common_name = NULL,
}

# symbols here are generally: %22 = ", %2C = ",", %20 = " "
species_str <- paste0("%22",stringr::str_replace_all(species[1]," ","%20"),"%22")
if(length(species) > 1) {
for(i in 2:length(species)) {
species_str <- paste0(species_str, "%2C", paste0("%22",stringr::str_replace_all(species[i]," ","%20"),"%22"))
}
}
species_str <- convert_to_hex_string(species)
add_species <- paste0("field_identified_taxonomy_dim$", var_name, "|=[", species_str,"]")

if (any(species == "pull all")) {
Expand Down
12 changes: 1 addition & 11 deletions R/pull_catch.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,7 @@ pull_catch <- function(common_name = NULL,
vars_short <- vars_long[!vars_long %in% perf_codes]

# symbols here are generally: %22 = ", %2C = ",", %20 = " "
species_str <- paste0(
"%22",stringr::str_replace_all(species[1]," ","%20"),"%22"
)

if(length(species) > 1) {
for(i in 2:length(species)) {
species_str <- paste0(
species_str, "%2C", paste0(
"%22",stringr::str_replace_all(species[i]," ","%20"),"%22"))
}
}
species_str <- convert_to_hex_string(species)
add_species <- paste0("field_identified_taxonomy_dim$", var_name, "|=[", species_str,"]")

if (any(species == "pull all")) {
Expand Down
31 changes: 31 additions & 0 deletions man/convert_to_hex_string.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e949cb4

Please sign in to comment.