Learn R Programming

cssTools (version 1.0)

cssTools2sna: Convert a CSS in cssTools Format to a CSS in sna Format

Description

Converts a CSS in cssTools package format to a CSS in sna package format.

Usage

cssTools2sna(d)

Arguments

d
A CSS in cssTools package format.

Value

The same CSS coded in sna format.

Details

In cssTools package, a CSS d is coded in a three dimensional array such that d[,,i] is the i-th slice. In sna package, the same object is coded in a three dimensional array such that d[i,,] is the i-th slice. The cssTools2sna function transforms cssTools format to sna format.

See Also

sna2cssTools

Examples

Run this code
# Consider the example in Siciliano et. al. (2012),
# a network with five actors A, B, C, D, E
sA=matrix(c(0,0,1,0,1,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0),5,5)
sB=matrix(c(0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,0,0),5,5)
sC=matrix(c(0,1,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0),5,5)
sD=matrix(c(0,0,1,0,1,0,0,1,1,0,1,1,0,0,0,0,1,0,0,1,1,0,0,1,0),5,5)
sE=matrix(c(0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,1,0),5,5)
d=array(dim=c(5,5,5))
d[,,1]=sA
d[,,2]=sB
d[,,3]=sC
d[,,4]=sD
d[,,5]=sE

# Here d is coded in cssTools package format
# Switching between sna and cssTools formats
e=cssTools2sna(d)
f=sna2cssTools(e)

Run the code above in your browser using DataLab