Skip to content

Commit

Permalink
Updated how lists and vectors are identified in gather_topics()
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquesposito committed Jun 14, 2024
1 parent 055c962 commit cd0cea5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/topic.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ gather_topics <- function(.data, dictionary = "CAP") {
stringr::str_squish(tolower(Words))), ", ", "|"))
subjects <- dictionary$Words
names(subjects) <- dictionary$Topic
} else if (is.list(dictionary)) {
subjects <- unlist(lapply(dictionary, function(x) paste0(x, collapse = "|")))
} else {
} else if (is.vector(dictionary) && is.atomic(dictionary)) {
subjects <- dictionary
names(subjects) <- subjects
} else {
subjects <- unlist(lapply(dictionary, function(x) paste0(x, collapse = "|")))
}
# match terms
out <- lapply(names(subjects), function(i) stringr::str_count(text, subjects[[i]]))
Expand Down

0 comments on commit cd0cea5

Please sign in to comment.