R/chartBigrams.R

Defines functions chartConnections

Documented in chartConnections

#' Chart bigrams
#'
#' @param bigrams df containing just word1 and word2
#'
#' @export
#'
#' @examples
#' df<-data.frame(word1=LETTERS[1:5], word2=LETTERS[2:6], n=1:5)
#' chartConnections(df)
#'
chartConnections <- function(bigrams) {
  igraph::graph_from_data_frame(bigrams) %>%
    ggraph::ggraph(layout = "fr") +
    ggraph::geom_edge_link() +
    ggraph::geom_node_point() +
    ggraph::geom_node_text(ggplot2::aes(label = name), vjust = 1, hjust = 1)+
    ggplot2::theme_void()
}
lockedata/TextAnalysis documentation built on Nov. 21, 2019, 10:08 p.m.