Description Usage Arguments Details Value Methods (by generic) Examples
The tbl_graph
class is a thin wrapper around an igraph
object that
provides methods for manipulating the graph using the tidy API. As it is just
a subclass of igraph
every igraph method will work as expected. A
grouped_tbl_graph
is the equivalent of a grouped_df
where either the
nodes or the edges has been grouped. The grouped_tbl_graph
is not
constructed directly but by using the group_by()
verb. After creation of a
tbl_graph
the nodes are activated by default. The context can be changed
using the activate()
verb and affects all subsequent operations. Changing
context automatically drops any grouping. The current active context can
always be extracted with as_tibble()
, which drops the graph structure and
just returns a tbl_df
or a grouped_df
depending on the state of the
tbl_graph
. The returned context can be overriden by using the active
argument in as_tibble()
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48  ## S3 method for class 'data.frame'
as_tbl_graph(x, directed = TRUE, ...)
## S3 method for class 'Node'
as_tbl_graph(x, directed = TRUE, mode = "out", ...)
## S3 method for class 'dendrogram'
as_tbl_graph(x, directed = TRUE, mode = "out",
...)
## S3 method for class 'graphNEL'
as_tbl_graph(x, ...)
## S3 method for class 'graphAM'
as_tbl_graph(x, ...)
## S3 method for class 'graphBAM'
as_tbl_graph(x, ...)
## S3 method for class 'hclust'
as_tbl_graph(x, directed = TRUE, mode = "out", ...)
## S3 method for class 'igraph'
as_tbl_graph(x, ...)
## S3 method for class 'list'
as_tbl_graph(x, directed = TRUE, ...)
## S3 method for class 'matrix'
as_tbl_graph(x, directed = TRUE, ...)
## S3 method for class 'network'
as_tbl_graph(x, ...)
## S3 method for class 'phylo'
as_tbl_graph(x, directed = NULL, ...)
## S3 method for class 'evonet'
as_tbl_graph(x, directed = TRUE, ...)
tbl_graph(nodes = NULL, edges = NULL, directed = TRUE)
as_tbl_graph(x, ...)
## Default S3 method:
as_tbl_graph(x, ...)
is.tbl_graph(x)

x 
An object convertible to a 
directed 
Should the constructed graph be directed (defaults to 
... 
Arguments passed on to the conversion function 
mode 
In case 
nodes 
A 
edges 
A 
Constructors are provided for most data structures that resembles networks.
If a class provides an igraph::as.igraph()
method it is automatically
supported.
A tbl_graph
object
as_tbl_graph
: Method for edge table and set membership table
as_tbl_graph
: Method to deal with Node objects from the data.tree package
as_tbl_graph
: Method for dendrogram objects
as_tbl_graph
: Method for handling graphNEL objects from the graph package (on Bioconductor)
as_tbl_graph
: Method for handling graphAM objects from the graph package (on Bioconductor)
as_tbl_graph
: Method for handling graphBAM objects from the graph package (on Bioconductor)
as_tbl_graph
: Method for hclust objects
as_tbl_graph
: Method for igraph object. Simply subclasses the object into a tbl_graph
as_tbl_graph
: Method for adjacency lists and lists of node and edge tables
as_tbl_graph
: Method for edgelist, adjacency and incidence matrices
as_tbl_graph
: Method to handle network objects from the network
package. Requires this packages to work.
as_tbl_graph
: Method for handling phylo objects from the ape package
as_tbl_graph
: Method for handling evonet objects from the ape package
as_tbl_graph
: Default method. tries to call igraph::as.igraph()
on the input.
1 2 3 4  rstat_nodes < data.frame(name = c("Hadley", "David", "Romain", "Julia"))
rstat_edges < data.frame(from = c(1, 1, 1, 2, 3, 3, 4, 4, 4),
to = c(2, 3, 4, 1, 1, 2, 1, 2, 3))
tbl_graph(nodes = rstat_nodes, edges = rstat_edges)

Attaching package: 'tidygraph'
The following object is masked from 'package:stats':
filter
# A tbl_graph: 4 nodes and 9 edges
#
# A directed simple graph with 1 component
#
# Node Data: 4 x 1 (active)
name
<fct>
1 Hadley
2 David
3 Romain
4 Julia
#
# Edge Data: 9 x 2
from to
<int> <int>
1 1 2
2 1 3
3 1 4
# ... with 6 more rows
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.