File: activate.Rd

package info (click to toggle)
r-cran-tidygraph 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 736 kB
  • sloc: cpp: 35; sh: 13; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,650 bytes parent folder | download | duplicates (3)
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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/activate.R
\name{activate}
\alias{activate}
\alias{active}
\alias{\%N>\%}
\alias{\%E>\%}
\title{Determine the context of subsequent manipulations}
\usage{
activate(.data, what)

active(x)

lhs \%N>\% rhs

lhs \%E>\% rhs
}
\arguments{
\item{.data, x, lhs}{A tbl_graph or a grouped_tbl_graph}

\item{what}{What should get activated? Possible values are \code{nodes} or
\code{edges}.}

\item{rhs}{A function to pipe into}
}
\value{
A tbl_graph
}
\description{
As a \link{tbl_graph} can be considered as a collection of two linked tables it is
necessary to specify which table is referenced during manipulations. The
\code{activate} verb does just that and needs affects all subsequent manipulations
until a new table is activated. \code{active} is a simple query function to get
the currently acitve context. In addition to the use of \code{activate} it is also
possible to activate nodes or edges as part of the piping using the \verb{\%N>\%}
and \verb{\%E>\%} pipes respectively. Do note that this approach somewhat obscures
what is going on and is thus only recommended for quick, one-line, fixes in
interactive use.
}
\note{
Activate will ungroup a grouped_tbl_graph.
}
\examples{
gr <- create_complete(5) \%>\%
  activate(nodes) \%>\%
  mutate(class = sample(c('a', 'b'), 5, TRUE)) \%>\%
  activate(edges) \%>\%
  arrange(from)

# The above could be achieved using the special pipes as well
gr <- create_complete(5) \%N>\%
  mutate(class = sample(c('a', 'b'), 5, TRUE)) \%E>\%
  arrange(from)
# But as you can see it obscures what part of the graph is being targeted

}