These functions reformat tie attributes like their weight or sign:
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 the "negative" ties, or "both",
which keeps every tie but replaces its sign with its magnitude.
to_positive() keeps just the positive ties of a signed network,
and returns an unsigned network unaltered.
It is a guard for the functions that cannot read a negative tie,
such as the path-based measures, for which a negative tie is hostility
rather than a channel.
to_normalised() rescales tie weights relative to the other ties of the
same node, so that a value reads as a share rather than a count,
or weights the ties of a two-mode network of documents and terms by
term frequency-inverse document frequency.
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_unsigned(.data, keep = c("positive", "negative", "both"))
to_positive(.data)
to_unweighted(.data, threshold = 1)
to_signed(.data, mark = NULL)
to_weighted(.data, measure = NULL)
to_normalised(
.data,
rule = c("max", "mean", "sum", "tfidf"),
across = c("both", "rows", "columns")
)
to_normalized(
.data,
rule = c("max", "mean", "sum", "tfidf"),
across = c("both", "rows", "columns")
)An object of a {manynet}-consistent class:
adjacency or incidence matrix from {base} R
edgelist data.frame from {base} R or tbl/tbl_df from {tibble}
stocnet stocnet, from the {manynet} package
igraph igraph, from the {igraph} package
network network, from the {network} package
tidygraph tbl_graph, from the {tidygraph} package
In the case of a signed network, whether to retain the "positive" or the "negative" ties, or "both", which retains every tie but replaces its sign with its magnitude.
For a matrix, the threshold to binarise/dichotomise at.
A mark (logical vector) the length of the ties in the network.
A numeric vector (measure) that will be added as the tie
weights to the network,
or the name of a numeric tie attribute whose values become the weights,
such as "length".
A length is a distance, so a long tie becomes a heavy one:
see tie_lengths() for when that is wanted.
If this is NULL, then the tie weights will be drawn from a
Poisson distribution with \(\lambda = 4\).
How each tie value is rescaled, relative to the other values recorded for the same node.
"max" (the default) divides by the largest of them, so that a node's strongest tie is 1 and its others are read against that.
"mean" divides by the average of them, counting every dyad and not just those tied, so that 1 marks a tie of typical strength.
"sum" divides by the total of them, so that they add to 1 and each reads as the share of the node's ties that goes to that partner.
"tfidf" weights the ties of a two-mode network of documents and terms
by term frequency-inverse document frequency.
Each tie is divided by the total of its document's ties, its term
frequency, and multiplied by \(\log(N/n_t)\), where \(N\) is the
number of documents and \(n_t\) the number of documents tied to the
term. A term that every document uses thus weighs 0, and a term that
few documents use weighs more. This is the definition of
tidytext::bind_tf_idf(). The documents are the rows, the first mode,
unless across = "columns", which makes them the columns.
Only a two-mode network has documents and terms, so a one-mode network
gives an error.
Missing values propagate rather than being ignored,
so that a node with an unobserved tie has all its values unobserved.
Use impute_ties() first to state a different assumption.
Which margin of the network the operation is taken over. "rows" is the sending margin, so that each node is treated by the ties it sends; "columns" is the receiving margin; and "both" combines them. The two margins coincide for an undirected network, where all three options therefore agree. A two-mode network raises no such question, so "rows" and "columns" there are just the two nodesets.
Note that both the default and what "both" combines differ by function.
to_normalised() defaults to "both", where it divides by the square root
of the two denominators multiplied together, since that is the only
rescaling that preserves a network's symmetry.
to_proximity() defaults to "rows", the conventional profile for
structural equivalence, and there "both" compares each node's sent and
received ties together.
An object of the same class as the function was given, modified as explained in the function description, details, or section. Functions that split a network return a list of such objects.
Not all functions have methods available for all object classes. Below are the currently implemented S3 methods:
data.frame default igraph matrix network stocnet tbl_graph
to_normalised * * * * * * *
to_signed * * * * * * *
to_unsigned * * * * * * *
to_unweighted * * * * * * *
to_weighted * * * *to_normalised() divides by the sending node's denominator for "rows",
so that a value says what share of \(i\)'s ties goes to \(j\),
and by the receiving node's denominator for "columns".
Rescaling a one-mode network across its rows or columns makes it asymmetric, since what \(i\) sends \(j\) is generally not what \(j\) sends \(i\). Where such a network is undirected, each tie is therefore split into two, and the network is returned directed.
Other ties:
manip_ties_attr,
manip_ties_num,
modif_backbone,
modif_direction,
modif_influence
Other modifications:
modif_backbone,
modif_concepts,
modif_direction,
modif_from_parts,
modif_from_ternary,
modif_influence,
modif_labels,
modif_layers,
modif_levels,
modif_loops,
modif_miss,
modif_motifs,
modif_paths,
modif_permutation,
modif_project,
modif_proximity,
modif_scope,
modif_split
marvel <- to_layer(fict_marvel, "relationship")
to_unsigned(marvel, "positive")
#>
#> ── # Marvel universe ───────────────────────────────────────────────────────────
#> # A labelled, undirected network of 53 nodes and 277 relationship ties
#> # Transformed by exclusion and symmetrisation
#>
#> ── Nodes
#> # A tibble: 53 × 10
#> label Gender Appearances Attractive Rich Intellect Omnilingual PowerOrigin
#> <chr> <chr> <int> <int> <int> <int> <int> <chr>
#> 1 Abomina… Male 427 0 0 1 1 Radiation
#> 2 Ant-Man Male 589 1 0 1 0 Human
#> 3 Apocaly… Male 1207 0 0 1 1 Mutant
#> 4 Beast Male 7609 1 0 1 0 Mutant
#> 5 Black P… Male 2189 1 1 1 0 Human
#> 6 Black W… Female 2907 1 0 1 0 Human
#> # ℹ 47 more rows
#> # ℹ 2 more variables: UnarmedCombat <int>, ArmedCombat <int>
#>
#> ── Ties
#> # A tibble: 277 × 3
#> from to weight
#> <int> <int> <dbl>
#> 1 2 25 1
#> 2 2 29 1
#> 3 2 44 1
#> 4 2 49 1
#> 5 3 24 1
#> 6 4 5 1
#> # ℹ 271 more rows
#>
to_unsigned(marvel, "both")
#> ── # Marvel universe ───────────────────────────────────────────────────────────
#> # A labelled, complex, undirected network of 53 nodes and 558 relationship ties
#> (138 parallel)
#> # Transformed by exclusion and symmetrisation
#>
#> ── Nodes
#> # A tibble: 53 × 10
#> label Gender Appearances Attractive Rich Intellect Omnilingual PowerOrigin
#> <chr> <chr> <int> <int> <int> <int> <int> <chr>
#> 1 Abomina… Male 427 0 0 1 1 Radiation
#> 2 Ant-Man Male 589 1 0 1 0 Human
#> 3 Apocaly… Male 1207 0 0 1 1 Mutant
#> 4 Beast Male 7609 1 0 1 0 Mutant
#> 5 Black P… Male 2189 1 1 1 0 Human
#> 6 Black W… Female 2907 1 0 1 0 Human
#> # ℹ 47 more rows
#> # ℹ 2 more variables: UnarmedCombat <int>, ArmedCombat <int>
#>
#> ── Ties
#> # A tibble: 558 × 3
#> from to weight
#> <int> <int> <dbl>
#> 1 1 1 1
#> 2 1 4 1
#> 3 1 11 1
#> 4 1 12 1
#> 5 1 23 1
#> 6 1 24 1
#> # ℹ 552 more rows
#>
to_positive(marvel)
#> ── # Marvel universe ───────────────────────────────────────────────────────────
#> # A labelled, undirected network of 53 nodes and 277 relationship ties
#> # Transformed by exclusion and symmetrisation
#>
#> ── Nodes
#> # A tibble: 53 × 10
#> label Gender Appearances Attractive Rich Intellect Omnilingual PowerOrigin
#> <chr> <chr> <int> <int> <int> <int> <int> <chr>
#> 1 Abomina… Male 427 0 0 1 1 Radiation
#> 2 Ant-Man Male 589 1 0 1 0 Human
#> 3 Apocaly… Male 1207 0 0 1 1 Mutant
#> 4 Beast Male 7609 1 0 1 0 Mutant
#> 5 Black P… Male 2189 1 1 1 0 Human
#> 6 Black W… Female 2907 1 0 1 0 Human
#> # ℹ 47 more rows
#> # ℹ 2 more variables: UnarmedCombat <int>, ArmedCombat <int>
#>
#> ── Ties
#> # A tibble: 277 × 3
#> from to weight
#> <int> <int> <dbl>
#> 1 2 25 1
#> 2 2 29 1
#> 3 2 44 1
#> 4 2 49 1
#> 5 3 24 1
#> 6 4 5 1
#> # ℹ 271 more rows
#>
to_normalised(ison_networkers, rule = "sum", across = "rows")
#> ── # EIES Networkers ───────────────────────────────────────────────────────────
#> # A labelled, weighted, directed network of 32 nodes and 440 arcs
#> # Transformed by normalisation: sum across rows
#>
#> ── Nodes
#> # A tibble: 32 × 3
#> label Discipline Citations
#> <chr> <chr> <dbl>
#> 1 Lin Freeman Sociology 19
#> 2 Doug White Anthropology 3
#> 3 Ev Rogers Other 170
#> 4 Richard Alba Sociology 23
#> 5 Phipps Arabie Other 16
#> 6 Carol Barner-Barry Other 6
#> # ℹ 26 more rows
#>
#> ── Ties
#> # A tibble: 440 × 3
#> from to weight
#> <int> <int> <dbl>
#> 1 1 2 0.154
#> 2 1 3 0.00883
#> 3 1 4 0.0205
#> 4 1 5 0.00631
#> 5 1 6 0.0205
#> 6 1 7 0.0142
#> # ℹ 434 more rows
#>