plot_group_term_network: Function to view top terms associated with a categorical...

View source: R/plot_group_term_network.R

plot_group_term_networkR Documentation

Function to view top terms associated with a categorical variable.

Description

Counts the top terms that appear in posts with a grouping variable. Individual instances of grouping variable (e.g. Nike, Adidas) who have common words in their top n_terms will be placed by graph-drawing algorithm closer to those they have none in common with. Terms common to all or multiple grouping variables will be drawn towards the middle of the network. Terms that are uniquely associated with a specific grouping variable will be draw outwards towards the periphery of the network.

Usage

plot_group_term_network(
  data,
  group_var = brand,
  text_var = message,
  n_terms = 20,
  with_ties = FALSE
)

Arguments

data

Your data frame - should have text variable and a grouping variable coded in.

group_var

The variable you wish to compare, should be a categorical or factor e.g. brand, entity, sentiment, country

text_var

The text variable

n_terms

Number of terms to select for each

with_ties

Whether to allow for > n_terms if terms have equal frequency in group_var's count

Value

A network visualisation of terms associated with a grouping variable

Examples

## Not run: 
Example 1:
plot_group_term_network(data, group_var = brand, text_var = text, n_terms = 15)

Example 2:
plot_group_term_network(my_data_frame, group_var = sentiment, text_var = message, n_terms = 15)

## End(Not run)

jpcompartir/JPackage documentation built on March 20, 2023, 4 a.m.