File: context_accessors.Rd

package info (click to toggle)
r-cran-tidygraph 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 736 kB
  • sloc: cpp: 35; sh: 13; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 1,222 bytes parent folder | download
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/context.R
\name{context_accessors}
\alias{context_accessors}
\alias{.G}
\alias{.N}
\alias{.E}
\title{Access graph, nodes, and edges directly inside verbs}
\usage{
.G()

.N()

.E()
}
\value{
Either a \code{tbl_graph} (\code{.G()}) or a \code{tibble} (\code{.N()})
}
\description{
These three functions makes it possible to directly access either the node
data, the edge data or the graph itself while computing inside verbs. It is
e.g. possible to add an attribute from the node data to the edges based on
the terminating nodes of the edge, or extract some statistics from the graph
itself to use in computations.
}
\section{Functions}{
\itemize{
\item \code{.G}: Get the tbl_graph you're currently working on

\item \code{.N}: Get the nodes data from the graph you're currently working on

\item \code{.E}: Get the edges data from the graph you're currently working on
}}

\examples{

# Get data from the nodes while computing for the edges
create_notable('bull') \%>\%
  activate(nodes) \%>\%
  mutate(centrality = centrality_power()) \%>\%
  activate(edges) \%>\%
  mutate(mean_centrality = (.N()$centrality[from] + .N()$centrality[to])/2)
}