refactor: remove widyr dependency

This commit is contained in:
Martin Chan 2020-12-18 13:45:58 +00:00
Родитель 6386f99651
Коммит 9b74d2175f
2 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -26,15 +26,16 @@
#' @import ggplot2 #' @import ggplot2
#' @import ggraph #' @import ggraph
#' @importFrom igraph graph_from_data_frame #' @importFrom igraph graph_from_data_frame
#' @importFrom widyr pairwise_count
#' @importFrom tidytext unnest_tokens #' @importFrom tidytext unnest_tokens
#' #'
#' @family Text-mining #' @family Text-mining
#' #'
#' @examples #' @examples
#' \dontrun{ #' # Demo using a subset of `mt_data`
#' tm_cooc(mt_data,lmult = 0.01) #' mt_data %>%
#' } #' dplyr::slice(1:20) %>%
#' tm_cooc(lmult = 0.01)
#'
#' @export #' @export
tm_cooc <- function(data, tm_cooc <- function(data,
stopwords = NULL, stopwords = NULL,
@ -50,10 +51,7 @@ tm_cooc <- function(data,
# Calculate frequency of pairs # Calculate frequency of pairs
title_word_pairs <- title_word_pairs <-
text_df %>% text_df %>%
widyr::pairwise_count(word, pairwise_count(id = "line", word = "word")
line,
sort = TRUE,
upper = FALSE)
# Graph networks # Graph networks
set.seed(seed) set.seed(seed)

Просмотреть файл

@ -29,9 +29,11 @@ There is an option to remove stopwords by passing a data frame into the \code{st
argument. argument.
} }
\examples{ \examples{
\dontrun{ # Demo using a subset of `mt_data`
tm_cooc(mt_data,lmult = 0.01) mt_data \%>\%
} dplyr::slice(1:20) \%>\%
tm_cooc(lmult = 0.01)
} }
\seealso{ \seealso{
Other Text-mining: Other Text-mining: