These functions reformat manynet-consistent data.
to_unnamed()
reformats labelled network data to unlabelled network data.
to_undirected()
reformats directed network data to an undirected network,
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_unweighted()
reformats weighted network data to unweighted network
data, with all tie weights removed.
to_unsigned()
reformats signed network data to unsigned network data
keeping just the "positive" or "negative" ties.
to_simplex()
reformats complex network data, containing loops, to simplex network data, without any loops.
to_uniplex()
reformats multiplex network data to a single type of tie.
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_unnamed(.data)
to_undirected(.data)
to_unweighted(.data, threshold = 1)
to_unsigned(.data, keep = c("positive", "negative"))
to_simplex(.data)
to_uniplex(.data, tie)
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
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 string naming a tie attribute to retain from a graph.
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_simplex | 1 | 1 | 1 | 1 | 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 |
Other modifications:
manip_as
,
manip_correlation
,
manip_from
,
manip_levels
,
manip_miss
,
manip_nodes
,
manip_paths
,
manip_permutation
,
manip_preformat
,
manip_project
,
manip_reformat
,
manip_scope
,
manip_split
,
manip_ties
as_tidygraph(create_filled(5)) %>%
mutate_ties(type = sample(c("friend", "enemy"), 10, replace = TRUE)) %>%
to_uniplex("friend")
#> # Filled network
#> # A undirected network of 5 nodes and 5 ties
#> # A tibble: 5 × 2
#> from to
#> <int> <int>
#> 1 1 3
#> 2 1 5
#> 3 2 4
#> 4 3 4
#> 5 4 5