View source: R/class-network.R
| as.data.frame.cograph_network | R Documentation |
The tidy accessor for a cograph_network: one row per edge (or per
node), with endpoints given as labels rather than internal indices, so no
caller has to reach into the object with $ or translate integer ids
by hand.
## S3 method for class 'cograph_network'
as.data.frame(
x,
row.names = NULL,
optional = FALSE,
...,
what = c("edges", "nodes")
)
x |
A |
row.names |
|
optional |
Logical, as for |
... |
Unused, for compatibility with the generic. |
what |
Which table to return. |
A base data frame. For what = "edges", one row per edge with
columns from and to (node labels), weight, and any
extra edge columns the network carries (for example session). For
what = "nodes", one row per node with the node metadata columns
(id, label, layout coordinates, and any custom columns).
This is the accessor, so it hands back everything the object holds,
including columns mutate_edges computed.
to_df is the narrower conversion verb: it returns
from, to and weight only.
to_df, get_edges, get_nodes
adj <- matrix(c(0, .5, .8, 0,
.5, 0, .3, .6,
.8, .3, 0, .4,
0, .6, .4, 0), 4, 4, byrow = TRUE)
rownames(adj) <- colnames(adj) <- c("A", "B", "C", "D")
net <- as_cograph(adj)
as.data.frame(net)
as.data.frame(net, what = "nodes")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.