igraph_from_matrices {ILSM}R Documentation

Transforming matrices into network

Description

Two matrices contain three groups of tropical level species. A multilayer network can be transformed from existing matrices data.

Usage

igraph_from_matrices(mat1, mat2, isDirected1 = TRUE, isDirected2 = TRUE)

Arguments

mat1

A numeric matrix(or data.frame) representing interactions between two groups of species.Each row and column of matrix represents single species in the second and first groups of the tripartite network respectively. Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise.

mat2

A numeric matrix(or data.frame) representing interactions between two groups of species.Each row and column of matrix represents single species in the second and third groups of the tripartite network respectively. Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise.

isDirected1

Logical. Whether the interaction between the two groups of species in mat1 is unidirectional.Default to TRUE, such as Predation and Herbivory. Otherwise it is bidirectional, such as Mutualism.

isDirected2

Logical. Whether the interaction between the two groups of species in mat2 is unidirectional.Default to TRUE, such as Predation and Herbivory. Otherwise it is bidirectional, such as Mutualism.

Details

mat1 and mat2

The type of inputting is data frame or matrix, please make sure the row of mat1 and mat2 correspond with the second group of species that both belong to two subnetworks and interact with other groups of species.

The columns of mat1 and mat2 could be empty. If empty, the function also defaults to the suggested assignment.

Value

Return a network of type "igraph".

Examples


set.seed(12)
MAT <- build_net(11,22,21,0.2,asmatrices=TRUE)
MAT[[1]]

tmat<-t(MAT[[3]])
colnames(tmat)<-NULL
igraph_from_matrices(MAT[[3]],MAT[[4]])
M <- igraph_from_matrices(tmat,MAT[[4]])
M

[Package ILSM version 1.0.3.1 Index]