Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Sep 12, 2023
1 parent d4aaac6 commit 8ec8b54
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions R/seek_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ seek_variables <- function(data, pattern, source = c("names", "labels"), fuzzy =
pos2 <- match(names(labels)[found], colnames(data))
# find in near distanc?
if (fuzzy) {
pos2 <- c(pos2, .fuzzy_grep(x = labels, pattern = search_pattern))
found <- .fuzzy_grep(x = labels, pattern = search_pattern)
if (length(found)) {
pos2 <- c(pos2, names(labels)[found])
}
}
}
}
Expand All @@ -104,7 +107,7 @@ seek_variables <- function(data, pattern, source = c("names", "labels"), fuzzy =
pos3 <- match(names(found)[found], colnames(data))
# find in near distance
if (fuzzy) {
pos3 <- which(vapply(
found <- vapply(
values,
function(i) {
p <- .fuzzy_grep(
Expand All @@ -114,7 +117,10 @@ seek_variables <- function(data, pattern, source = c("names", "labels"), fuzzy =
!insight::is_empty_object(p[1])
},
logical(1)
))
)
if (length(found)) {
pos3 <- c(pos3, match(names(found)[found], colnames(data)))
}
}
}
}
Expand Down

0 comments on commit 8ec8b54

Please sign in to comment.