Skip to contents

plot_actor_stats generates visualizations for actor-level statistics using the output from the summary_actor function. The function supports both cross-sectional and longitudinal data, offering insights into the distribution of statistics across actors or focusing on specific actors over time.

Usage

plot_actor_stats(
  summary_df,
  longitudinal = ifelse("time" %in% colnames(summary_df), TRUE, FALSE),
  multilayer = ifelse("layer" %in% colnames(summary_df), TRUE, FALSE),
  across_actor = TRUE,
  specific_stats = NULL,
  specific_actors = NULL
)

Arguments

summary_df

A dataframe from the summary_actor function containing actor-level or actor-time level statistics. The dataframe should have columns labeled "actor" and "time" for longitudinal data.

longitudinal

Logical; if TRUE, the data is considered longitudinal. Default is set to TRUE if there is a "time" column in the dataframe passed to summary_df.

multilayer

Logical; if TRUE, the data is considered to be multilayered. Default is set to TRUE if there is a "layer" column in the dataframe passed to summary_df.

across_actor

Logical; if TRUE, visualizations will focus on the distribution of statistics across actors. If FALSE, visualizations will focus on specific actors. Default is TRUE. If setting across_actor to TRUE and specific actors are provided, the data will be subsetted to include only the specified actors.

specific_stats

Optional; a vector of specific statistics to plot. If NULL, all available statistics in the dataframe are used. If specified, the function will check if these statistics are present in the dataframe and will subset the data accordingly.

specific_actors

Optional; a vector of specific actor names for which statistics will be plotted. When NULL, statistics for all actors are considered. If specified, the function will check if these actors are present in the dataframe and will subset the data accordingly. This parameter is relevant only if across_actor is set to FALSE.

Value

A ggplot object representing the requested visualization, which can be further customized or printed.

Details

This function can generate different types of plots based on the structure of the input data:

  • For cross-sectional data, it will show the distribution of statistics across actors using density plots or compare specific actors using various plot types.

  • For longitudinal data, it will show how the distribution of statistics changes over time using ridge density plots or track changes in statistics for specific actors over time using line plots.

Author

Cassy Dorff, Shahryar Minhas