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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data_frame.R, R/data_tree.R, R/dendrogram.R,
% R/graph.R, R/hclust.R, R/igraph.R, R/list.R, R/matrix.R, R/network.R,
% R/phylo.R, R/tbl_graph.R
\name{as_tbl_graph.data.frame}
\alias{as_tbl_graph.data.frame}
\alias{as_tbl_graph.Node}
\alias{as_tbl_graph.dendrogram}
\alias{as_tbl_graph.graphNEL}
\alias{as_tbl_graph.graphAM}
\alias{as_tbl_graph.graphBAM}
\alias{as_tbl_graph.hclust}
\alias{as_tbl_graph.igraph}
\alias{as_tbl_graph.list}
\alias{as_tbl_graph.matrix}
\alias{as_tbl_graph.network}
\alias{as_tbl_graph.phylo}
\alias{as_tbl_graph.evonet}
\alias{tbl_graph}
\alias{as_tbl_graph}
\alias{as_tbl_graph.default}
\alias{is.tbl_graph}
\title{A data structure for tidy graph manipulation}
\usage{
\method{as_tbl_graph}{data.frame}(x, directed = TRUE, ...)
\method{as_tbl_graph}{Node}(x, directed = TRUE, mode = "out", ...)
\method{as_tbl_graph}{dendrogram}(x, directed = TRUE, mode = "out", ...)
\method{as_tbl_graph}{graphNEL}(x, ...)
\method{as_tbl_graph}{graphAM}(x, ...)
\method{as_tbl_graph}{graphBAM}(x, ...)
\method{as_tbl_graph}{hclust}(x, directed = TRUE, mode = "out", ...)
\method{as_tbl_graph}{igraph}(x, ...)
\method{as_tbl_graph}{list}(x, directed = TRUE, node_key = "name", ...)
\method{as_tbl_graph}{matrix}(x, directed = TRUE, ...)
\method{as_tbl_graph}{network}(x, ...)
\method{as_tbl_graph}{phylo}(x, directed = NULL, ...)
\method{as_tbl_graph}{evonet}(x, directed = TRUE, ...)
tbl_graph(nodes = NULL, edges = NULL, directed = TRUE, node_key = "name")
as_tbl_graph(x, ...)
\method{as_tbl_graph}{default}(x, ...)
is.tbl_graph(x)
}
\arguments{
\item{x}{An object convertible to a \code{tbl_graph}}
\item{directed}{Should the constructed graph be directed (defaults to \code{TRUE})}
\item{...}{Arguments passed on to the conversion function}
\item{mode}{In case \code{directed = TRUE} should the edge direction be away from
node or towards. Possible values are \code{"out"} (default) or \code{"in"}.}
\item{node_key}{The name of the column in \code{nodes} that character represented
\code{to} and \code{from} columns should be matched against. If \code{NA} the first column
is always chosen. This setting has no effect if \code{to} and \code{from} are given as
integers.}
\item{nodes}{A \code{data.frame} containing information about the nodes in the
graph. If \code{edges$to} and/or \code{edges$from} are characters then they will be
matched to the column named according to \code{node_key} in nodes, if it exists.
If not, they will be matched to the first column.}
\item{edges}{A \code{data.frame} containing information about the edges in the
graph. The terminal nodes of each edge must either be encoded in a \code{to} and
\code{from} column, or in the two first columns, as integers. These integers refer to
\code{nodes} index.}
}
\value{
A \code{tbl_graph} object
}
\description{
The \code{tbl_graph} class is a thin wrapper around an \code{igraph} object that
provides methods for manipulating the graph using the tidy API. As it is just
a subclass of \code{igraph} every igraph method will work as expected. A
\code{grouped_tbl_graph} is the equivalent of a \code{grouped_df} where either the
nodes or the edges has been grouped. The \code{grouped_tbl_graph} is not
constructed directly but by using the \code{\link[=group_by]{group_by()}} verb. After creation of a
\code{tbl_graph} the nodes are activated by default. The context can be changed
using the \code{\link[=activate]{activate()}} verb and affects all subsequent operations. Changing
context automatically drops any grouping. The current active context can
always be extracted with \code{\link[=as_tibble]{as_tibble()}}, which drops the graph structure and
just returns a \code{tbl_df} or a \code{grouped_df} depending on the state of the
\code{tbl_graph}. The returned context can be overriden by using the \code{active}
argument in \code{\link[=as_tibble]{as_tibble()}}.
}
\details{
Constructors are provided for most data structures that resembles networks.
If a class provides an \code{\link[igraph:as.igraph]{igraph::as.igraph()}} method it is automatically
supported.
}
\section{Functions}{
\itemize{
\item \code{as_tbl_graph(data.frame)}: Method for edge table and set membership table
\item \code{as_tbl_graph(Node)}: Method to deal with Node objects from the data.tree package
\item \code{as_tbl_graph(dendrogram)}: Method for dendrogram objects
\item \code{as_tbl_graph(graphNEL)}: Method for handling graphNEL objects from the graph package (on Bioconductor)
\item \code{as_tbl_graph(graphAM)}: Method for handling graphAM objects from the graph package (on Bioconductor)
\item \code{as_tbl_graph(graphBAM)}: Method for handling graphBAM objects from the graph package (on Bioconductor)
\item \code{as_tbl_graph(hclust)}: Method for hclust objects
\item \code{as_tbl_graph(igraph)}: Method for igraph object. Simply subclasses the object into a \code{tbl_graph}
\item \code{as_tbl_graph(list)}: Method for adjacency lists and lists of node and edge tables
\item \code{as_tbl_graph(matrix)}: Method for edgelist, adjacency and incidence matrices
\item \code{as_tbl_graph(network)}: Method to handle network objects from the \code{network}
package. Requires this packages to work.
\item \code{as_tbl_graph(phylo)}: Method for handling phylo objects from the ape package
\item \code{as_tbl_graph(evonet)}: Method for handling evonet objects from the ape package
\item \code{as_tbl_graph(default)}: Default method. tries to call \code{\link[igraph:as.igraph]{igraph::as.igraph()}} on the input.
}}
\examples{
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)
}
|