зеркало из https://github.com/microsoft/wpa.git
refactor: remove widyr dependency
This commit is contained in:
Родитель
6386f99651
Коммит
9b74d2175f
14
R/tm_cooc.R
14
R/tm_cooc.R
|
@ -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:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче