Learn R Programming

tna (version 1.5.8)

sna: Build a Social Network Analysis Model

Description

Build a Social Network Analysis Model

Usage

sna(x, aggregate = sum, ...)

Value

A tna object representing the model. Its weights element is a square matrix with one row and column per state, holding the aggregated weight of each pair of states (zero when the pair does not occur). The inits and data elements are NULL.

Arguments

x

A data.frame or a matrix with three columns: the first two representing the states and the third giving the weights.

aggregate

A function to use for aggregating the weights. The default is sum().

...

Additional arguments passed to aggregate.

Examples

Run this code
set.seed(123)
states <- c("A", "B", "C", "D")
d <- data.frame(
  from = sample(states, 100, replace = TRUE),
  to = sample(states, 100, replace = TRUE),
  weight = rexp(100)
)
model <- sna(d)

Run the code above in your browser using DataLab