% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/create_multilayer_network.R
\name{create_multilayer_network}
\alias{create_multilayer_network}
\title{Create Multilayer Network}
\usage{
create_multilayer_network(
  list_of_layers,
  bipartite,
  directed,
  interlayer_links = NULL,
  layer_attributes = NULL,
  state_node_attributes = NULL,
  physical_node_attributes = NULL
)
}
\arguments{
\item{list_of_layers}{List of matrices or list of link lists (format
\code{from to weight}; see description). These are the intralayer links.}

\item{bipartite}{Is the network bipartite? Must be provided (no default
value).}

\item{directed}{Is the network directed? Must be provided (no default value).}

\item{interlayer_links}{Interlayer extended edge list of the format
\code{layer_from node_from layer_to node_to weight}. Default is NULL,
assuming no interlayer links.}

\item{layer_attributes}{Optional. A data frame with layer attributes. The
first column must be called \code{layer_id}, and it must have unique values (one row per layer).
Layer name column, if exists must be called \code{layer_name}, and its values must be unique. The
order of the rows and layer_id should be the same as in \code{list_of_layers}.
No column is allowed to be named \code{name}.}

\item{state_node_attributes}{Optional. Additional information on physical nodes in
layers. Must contain columns \code{layer_name} and \code{node_name}.}

\item{physical_node_attributes}{Optional. Additional information on physical nodes. Must contain column \code{node_name}.}
}
\value{
A multilayer object (see ?multilayer).
}
\description{
This function creates a multilayer network from multiple matrices / link
lists.
}
\details{
Input of \code{list_of_layers} is handled by the function
  \code{create_monolayer_network}; see it's description for details on input.
  If using matrices as input, they should contain row and column names. If link lists are provided as input column names should be
  \code{from to weight}.

  When using link lists, it is possible to include link
  attributes. In that case the headers of all the link lists and, if
  included, the interlayer links, must be the same (after the weight), even if some attributes
  are included in only some layers (see detailed example in the code accompanying the package). Missing link attributes can be set to \code{NA}.

  If interlayer links are provided, then layer_attributes must also be
  provided. Specify layer and nodes by UNIQUE names (not IDs). Layer names should
  correspond to those provided in layer_attributes.

  Attributes of state nodes can be provided with \code{state_node_attributes}. If
  provided, then columns \code{layer_name} and \code{node_name} must be
  included.

  For compatibility with function \code{load_emln} the output contains
  \code{description} and \code{references}. The value of any missing data
  frames in the multilayer object will be set to NULL.

  See multiple example in the code accompanying the package
}
\examples{
library(tibble)
pond_1 <- matrix(c(0,1,1,0,0,1,0,0,0), byrow = TRUE,
nrow = 3, ncol = 3, dimnames = list(c('pelican','fish','crab'),
c('pelican','fish','crab')))
pond_2 <- matrix(c(0,1,0,0,0,1,0,0,0), byrow = TRUE,
nrow = 3, ncol = 3, dimnames = list(c('pelican','fish','crab'),
c('pelican','fish','crab')))
pond_3 <- matrix(c(0,1,1,0,0,1,0,0,0), byrow = TRUE,
nrow = 3, ncol = 3, dimnames = list(c('pelican','fish','tadpole'),
c('pelican','fish','tadpole')))

layer_attrib <- tibble(layer_id=1:3,
                       layer_name=c('pond_1','pond_2','pond_3'),
                       location=c('valley','mid-elevation','uphill'))

# Create the ELL tibble with interlayer links.
interlayer <- tibble(layer_from=c('pond_1','pond_1','pond_1'),
                     node_from=c('pelican','crab','pelican'),
                     layer_to=c('pond_2','pond_2','pond_3'),
                    node_to=c('pelican','crab','pelican'),
                     weight=1)

# This is a directed network so the links should go both ways,
# even though they are symmetric.
interlayer_2 <- interlayer[,c(3,4,1,2,5)]
names(interlayer_2) <- names(interlayer)
interlayer <- rbind(interlayer, interlayer_2)

multilayer <- create_multilayer_network(list_of_layers =
list(pond_1, pond_2, pond_3), layer_attributes = layer_attrib,
interlayer_links = interlayer, bipartite = FALSE, directed = TRUE)

}
\seealso{
\code{multilayer, create_monolayer_network}
}
