View source: R/make_index_ids.R
| make_index_ids | R Documentation |
makes index ids for the provided hy object. These can be used for graph traversal algorithms such that the row number and id are equal.
make_index_ids(x, mode = "to", long_form = NULL)
## S3 method for class 'data.frame'
make_index_ids(x, mode = "to", long_form = NULL)
## S3 method for class 'hy'
make_index_ids(x, mode = "to", long_form = NULL)
## S3 method for class 'hy_flownetwork'
make_index_ids(x, mode = "to", long_form = NULL)
## S3 method for class 'hy_topo'
make_index_ids(x, mode = "to", long_form = NULL)
x |
data.frame network compatible with hydroloom_names. |
mode |
character indicating the mode of the graph. Choose from "to", "from", or "both". Default is "to". Se Details for more information. |
long_form |
logical DEPRECATED |
Required attributes: id, toid
mode determines the direction of the graph. If "to", the graph will
be directed from the id to the toid. If "from", the graph will be
directed from the toid to the id. If "both", the list will contain both
a "from" and a "to" element containing each version of the graph.
list containing named elements:
adjacency matrix with columns that correspond to unqiue(x$id)
vector indicating the number of connections from each node
a data.frame with an id, indid and a toindid list column.
List will have names froms, lengths, and froms_list for mode "from".
NOTE: the long_form output is deprecated and will be removed in a future release.
x <- data.frame(
id = c(1, 2, 3, 4, 5, 6, 7, 8, 9),
toid = c(2, 3, 4, 5, 0, 7, 8, 9, 4)
)
make_index_ids(x, mode = "to")
make_index_ids(x, mode = "from")
make_index_ids(x, mode = "both")
x <- hy(sf::read_sf(system.file("extdata/new_hope.gpkg", package = "hydroloom")))
x <- add_toids(x, return_dendritic = FALSE)
x <- make_index_ids(x)
names(x)
class(x$to)
class(x$lengths)
class(x$to_list)
is.list(x$to_list$toindid)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.