Closed trinker closed 7 years ago
Easy way to turn vector of terms into term.list:
#' Title #' #' Description #' #' @param x #' @param \ldots #' @return #' @references #' @keywords #' @export #' @seealso #' @examples #' \dontrun{ #' if (!require("pacman")) install.packages("pacman") #' pacman::p_load(tidyverse) #' #' bigrams <- ngram_collocations(x, n=10) %>% #' transmute(bigram = paste(term1, term2)) %>% #' unlist() %>% #' as_term_list() #' #' #' presidential_debates_2012 %>% #' with(term_count(dialogue, person, bigrams)) #' } as_term_list <- function(x, ...){ stopifnot(is.atomic(x)) stats::setNames(as.list(x), gsub('\\s+', '_', x)) }
Easy way to turn vector of terms into term.list: