This function processes the input data to create an igraph object and then generates an interactive network plot based on the specified plot type. The plot can show the entire network, the largest component with a single color, or the largest component with different colors based on community detection. Node size and edge width are scaled based on node degree and edge weight, respectively.
Usage
plot_networkD3(
data,
col1 = "word1",
col2 = "word2",
plot_type = c("whole_network", "biggest_component_one_color",
"biggest_component_community_color"),
threshold,
node_size = 20,
edges_width = 10,
opacity = 1,
font_size = 15,
...
)
Arguments
- data
A data frame containing the edge list for the network.
- col1, col2
The name of two columns containing the symbolic edge list. Default is "word1" and "word2", respectively.
- plot_type
A character string specifying the type of plot to generate. Options are "whole_network", "biggest_component_one_color", and "biggest_component_community_color". Default is "whole_network".
- threshold
An integer specifying the minimum frequency of edges to be included in the network.
- node_size
A numeric value specifying the base size of the nodes. Default is 20.
- edges_width
A numeric value specifying the base width of the edges. Default is 10.
- opacity
A numeric value specifying the opacity of the graph elements. Default is 1.
- font_size
A numeric value specifying the font size of the node labels. Default is 15.
- ...
Additional arguments passed to
networkD3::forceNetwork()
.
Examples
library(janeaustenr)
data <- austen_books() %>%
ngrams_filter(group_column = "book",
group_name = "Pride & Prejudice",
text_column = "text",
ngrams = 2)
# The whole network plot
plot_networkD3(data = data,
threshold = 10)
# The biggest component plot with one color
plot_networkD3(data = data,
plot_type = "biggest_component_one_color",
threshold = 10)
# The biggest component plot with community based color
plot_networkD3(data = data,
plot_type = "biggest_component_community_color",
threshold = 10)