mirror of
https://github.com/msberends/AMR.git
synced 2026-10-01 04:13:33 +02:00
(v0.7.1.9013) guess_mo_ab speed improvement
This commit is contained in:
1 parent
68230d0712
commit
c652c6913f
12 files changed
+227
-216
No files matched your search
@@ -79,6 +79,13 @@ guess_ab_col <- function(x = NULL, search_string = NULL, verbose = FALSE) {
|
||||
search_string.ab <- suppressWarnings(as.ab(search_string))
|
||||
if (search_string.ab %in% colnames(x)) {
|
||||
ab_result <- colnames(x)[colnames(x) == search_string.ab][1L]
|
||||
|
||||
} else if (any(tolower(colnames(x)) %in% tolower(unlist(ab_property(search_string.ab, "abbreviations"))))) {
|
||||
ab_result <- colnames(x)[tolower(colnames(x)) %in% tolower(unlist(ab_property(search_string.ab, "abbreviations")))][1L]
|
||||
|
||||
# } else if (any(tolower(colnames(x)) %in% tolower(ab_tradenames(search_string.ab)))) {
|
||||
# ab_result <- colnames(x)[tolower(colnames(x)) %in% tolower(ab_tradenames(search_string.ab))][1L]
|
||||
|
||||
} else {
|
||||
# sort colnames on length - longest first
|
||||
cols <- colnames(x[, x %>% colnames() %>% nchar() %>% order() %>% rev()])
|
||||
|
||||
@@ -97,8 +97,10 @@ search_type_in_df <- function(x, type) {
|
||||
if (type == "mo") {
|
||||
if ("mo" %in% lapply(x, class)) {
|
||||
found <- colnames(x)[lapply(x, class) == "mo"][1]
|
||||
} else if (any(colnames(x) %like% "^(mo|microorganism|organism|bacteria)s?$")) {
|
||||
found <- colnames(x)[colnames(x) %like% "^(mo|microorganism|organism|bacteria)s?$"][1]
|
||||
} else if (any(colnames(x) %like% "^(mo|microorganism|organism|bacteria|bacterie)s?$")) {
|
||||
found <- colnames(x)[colnames(x) %like% "^(mo|microorganism|organism|bacteria|bacterie)s?$"][1]
|
||||
} else if (any(colnames(x) %like% "^(microorganism|organism|bacteria|bacterie)")) {
|
||||
found <- colnames(x)[colnames(x) %like% "^(microorganism|organism|bacteria|bacterie)"][1]
|
||||
} else if (any(colnames(x) %like% "species")) {
|
||||
found <- colnames(x)[colnames(x) %like% "species"][1]
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user