Learn R Programming

rENA (version 0.3.0)

add_nodes: Add nodes to an ENA plot

Description

This function adds nodes to an existing ENA plot or ENA set. It can be used to customize the nodes displayed on the plot, including their size and other graphical parameters.

Usage

add_nodes(x, ..., return_plot = FALSE)

Value

Invisibly returns the modified plot or ENA set, depending on the value of return_plot.

Arguments

x

An ENAplot object or an ENA set containing plots.

...

Additional arguments passed to ena.plot.points, such as nodes, size, and other graphical parameters.

return_plot

Logical; if TRUE, returns the modified ENA set. If FALSE (default), returns the modified plot invisibly.

Details

If x is an ENAplot, the function extracts the associated ENA set and plot. Otherwise, it assumes x is an ENA set and uses the last plot in the set. The nodes to be added can be specified via the nodes argument; otherwise, the default nodes from the set's rotation are used. Node size can be customized via the size argument.

The function updates the plot with the new nodes and stores the updated plot back in the ENA set.

Examples

Run this code
# Load test data
data(RS.data);

# Define codenames for the test
codenames <- c("Data", "Technical.Constraints", "Performance.Parameters",
  "Client.and.Consultant.Requests", "Design.Reasoning", "Collaboration");

# Standard ENA accumulation
accum <- rENA:::ena.accumulate.data.file(
  RS.data, units.by = c("UserName", "Condition"),
  conversations.by = c("ActivityNumber", "GroupName"),
  codes = codenames
);
# Create a standard ENA set 
newset <- ena.make.set(accum);

# Simple plot for a set of points, and their mean
newplot <- plot(newset) |> 
  add_points(Condition$FirstGame, mean = TRUE, colors = "blue") |> 
  add_network();

# Plot a single unit's point and it's line.weights
plot(newset) |> 
  add_points(UserName$`steven z`) |> 
  add_network();

# Trajectory accumulation and plotting
trajectory_accumulation <- rENA:::ena.accumulate.data.file(
  RS.data, units.by = c("UserName", "Condition"),
  conversations.by = c("ActivityNumber", "GroupName"),
  codes = codenames,
  model = "A"
);
trajectory_model <- ena.make.set(trajectory_accumulation);

newplot3 <- plot(trajectory_model) |> 
  add_trajectory(Condition$FirstGame);

Run the code above in your browser using DataLab