These functions reformat manynet-consistent data.
to_uniplex()
reformats multiplex network data to a single type of tie.
to_undirected()
reformats directed network data to an undirected network.
to_directed()
reformats undirected network data to a directed network.
to_redirected()
reformats the direction of directed network data, flipping any existing direction.
to_reciprocated()
reformats directed network data such that every directed tie is reciprocated.
to_acyclic()
reformats network data to an acyclic graph.
to_unweighted()
reformats weighted network data to unweighted network data.
to_unsigned()
reformats signed network data to unsigned network data.
to_unnamed()
reformats labelled network data to unlabelled network data.
to_named()
reformats unlabelled network data to labelled network data.
to_simplex()
reformats complex network data, containing loops, to simplex network data, without any loops.
to_anti()
reformats network data into its complement, where only ties not present in the original network
are included in the new network.
If the format condition is not met,
for example to_undirected()
is used on a network that is already undirected,
the network data is returned unaltered.
No warning is given so that these functions can be used to ensure conformance.
Unlike the as_*()
group of functions,
these functions always return the same class as they are given,
only transforming these objects' properties.
to_uniplex(.data, tie)
to_undirected(.data)
to_directed(.data)
to_redirected(.data)
to_reciprocated(.data)
to_acyclic(.data)
to_unweighted(.data, threshold = 1)
to_unsigned(.data, keep = c("positive", "negative"))
to_unnamed(.data)
to_named(.data, names = NULL)
to_simplex(.data)
to_anti(.data)
An object of a manynet-consistent class:
matrix (adjacency or incidence) from {base}
R
edgelist, a data frame from {base}
R or tibble from {tibble}
igraph, from the {igraph}
package
network, from the {network}
package
tbl_graph, from the {tidygraph}
package
Character string naming a tie attribute to retain from a graph.
For a matrix, the threshold to binarise/dichotomise at.
In the case of a signed network, whether to retain the "positive" or "negative" ties.
Character vector of the node names. NULL by default.
All to_
functions return an object of the same class as that provided.
So passing it an igraph object will return an igraph object
and passing it a network object will return a network object,
with certain modifications as outlined for each function.
Not all functions have methods available for all object classes. Below are the currently implemented S3 methods:
data.frame | igraph | matrix | network | tbl_graph | |
to_acyclic | 1 | 1 | 1 | 1 | 1 |
to_directed | 1 | 1 | 1 | 1 | 1 |
to_named | 1 | 1 | 1 | 1 | 1 |
to_reciprocated | 1 | 1 | 1 | 1 | 1 |
to_redirected | 1 | 1 | 1 | 1 | 1 |
to_simplex | 0 | 1 | 1 | 0 | 1 |
to_undirected | 1 | 1 | 1 | 1 | 1 |
to_uniplex | 1 | 1 | 1 | 1 | 1 |
to_unnamed | 1 | 1 | 1 | 1 | 1 |
to_unsigned | 1 | 1 | 1 | 1 | 1 |
to_unweighted | 1 | 1 | 1 | 1 | 1 |
to_undirected()
: Returns an object that has any edge direction removed,
so that any pair of nodes with at least one directed edge will be
connected by an undirected edge in the new network.
This is equivalent to the "collapse" mode in {igraph}
.
to_redirected()
: Returns an object that has any edge direction transposed,
or flipped, so that senders become receivers and receivers become senders.
This essentially has no effect on undirected networks or reciprocated ties.
to_reciprocated()
: Returns an object where all ties are reciprocated.
to_unweighted()
: Returns an object that has all edge weights removed.
to_unsigned()
: Returns a network with either just the "positive" ties
or just the "negative" ties
to_unnamed()
: Returns an object with all vertex names removed
to_named()
: Returns an object that has random vertex names added
to_simplex()
: Returns an object that has all loops or self-ties removed
Other modifications:
manip_as
,
manip_correlation
,
manip_from
,
manip_levels
,
manip_miss
,
manip_nodes
,
manip_paths
,
manip_permutation
,
manip_project
,
manip_scope
,
manip_split
,
manip_ties
as_tidygraph(create_filled(5)) %>%
mutate_ties(type = sample(c("friend", "enemy"), 10, replace = TRUE)) %>%
to_uniplex("friend")
#> # A undirected network of 5 nodes and 6 ties
#> # A tibble: 6 × 2
#> from to
#> <int> <int>
#> 1 1 4
#> 2 1 5
#> 3 2 3
#> 4 2 4
#> 5 3 4
#> 6 3 5
to_anti(ison_southern_women)
#> # A labelled, two-mode network of 32 nodes and 163 ties
#> # A tibble: 32 × 2
#> type name
#> <lgl> <chr>
#> 1 FALSE Evelyn
#> 2 FALSE Laura
#> 3 FALSE Theresa
#> 4 FALSE Brenda
#> 5 FALSE Charlotte
#> 6 FALSE Frances
#> # ℹ 26 more rows
#> # A tibble: 163 × 2
#> from to
#> <int> <int>
#> 1 1 25
#> 2 1 28
#> 3 1 29
#> 4 1 30
#> 5 1 31
#> 6 1 32
#> # ℹ 157 more rows
#graphr(to_anti(ison_southern_women))