Learn R Programming

multiplex (version 3.7)

transf: Transform Data from/to Matrix/List Formats

Description

Function to transform data from/to matrix/list formats or edge list representing a network.

Usage

transf(x, type = c("toarray", "tolist", "toarray2", "toedgel"), lbs = NULL, lb2lb, 
    sep, ord, sort, sym, add, adc, na.rm)

Value

Depending on the input data, the result is either a list of pair relations or a matrix of relations.

Arguments

x

an array or a list of pair relations

type

type of transformation:

  • toarray from a list of pair relations to an array format

  • tolist from a matrix to a list of pair relations

  • toarray2 from a list of pair relations to a square array

  • toedgel from arrays to edge list

lbs

(optional) the labels in the transformation

lb2lb

(optional and logical) whether the transformation is label-to-label. Default TRUE for "toarray" and FALSE for "tolist"

sep

(optional) pair separator used for the pairwise relations

ord

(optional) for "toarray", the order of the resulted structure

sort

(optional and logical) sort the arrays in the output?

sym

(optional and logical) for "toarray", symmetrize the arrays?

add

(optional) added elements in the array's domain

adc

(optional) added elements in the array's codomain

na.rm

(optional) remove missing data in NA?

Author

Antonio Rivero Ostoic

Details

Option "tolist" is for transforming a matrix or an array to a list of pair elements. In case that the lb2lb is enabled in this type of transformation, then lbs must be provided, whereas the pair separator is optional. On the other hand, "toarray" will produce a matrix from a list of pair elements, and in this case is advisable to specify the order of the structure. Three dimensional structures are supported in the transformations with all options.

Data frames are also accepted for the "tolist" option; however, in case that this information is given as a list of pair relations the output will be a square matrix.

When the transformation option is "edgel", the output is a data frame with the first two columns for the sending and receiving ties. For simple networks, these two columns are enough and for multiplex networks additional columns are for the types of tie, one for each (cf. function edgel).

See Also

edgel, bundles, reduc, rel.sys

Examples

Run this code
# scan the multiplication table data
s <- matrix(data=c(1, 1, 1, 3, 3, 3, 3, 3, 3), nrow=3, ncol=3, byrow=TRUE)

# transform the matrix to a list format
s |> transf(lb2lb = TRUE, lbs = c("n","m","u"))

Run the code above in your browser using DataLab