graph_conversion function

Convert networks to graph objects

Convert networks to graph objects

The method as.igraph() converts nma_data objects into the form used by the igraph package. The method as_tbl_graph()

converts nma_data objects into the form used by the ggraph and tidygraph packages.

## S3 method for class 'nma_data' as.igraph(x, ..., collapse = TRUE) ## S3 method for class 'nma_data' as_tbl_graph(x, ...)

Arguments

  • x: An nma_data object to convert
  • ...: Additional arguments
  • collapse: Logical, collapse edges over studies? Default TRUE, only one edge is produced for each comparison (by IPD or AgD study type) with a .nstudy attribute giving the number of studies making that comparison. If FALSE, repeated edges are added for each study making the comparison.

Returns

An igraph object for as.igraph(), a tbl_graph object for as_tbl_graph().

Examples

# Set up network of smoking cessation data head(smoking) smk_net <- set_agd_arm(smoking, study = studyn, trt = trtc, r = r, n = n, trt_ref = "No intervention") # Print details smk_net # Convert to igraph object igraph::as.igraph(smk_net) # Edges combined by default igraph::as.igraph(smk_net, collapse = FALSE) # Without combining edges # Convert to tbl_graph object tidygraph::as_tbl_graph(smk_net) # Edges combined by default tidygraph::as_tbl_graph(smk_net, collapse = FALSE) # Without combining edges