1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/add_grid_2d.R 3\name{add_grid_2d} 4\alias{add_grid_2d} 5\title{Add a 2D grid of nodes to the graph} 6\usage{ 7add_grid_2d( 8 graph, 9 x, 10 y, 11 type = NULL, 12 label = TRUE, 13 rel = NULL, 14 node_aes = NULL, 15 edge_aes = NULL, 16 node_data = NULL, 17 edge_data = NULL 18) 19} 20\arguments{ 21\item{graph}{A graph object of class \code{dgr_graph}.} 22 23\item{x}{The number of nodes in the x direction.} 24 25\item{y}{The number of nodes in the y direction.} 26 27\item{type}{An optional string that describes the entity type for the nodes 28to be added.} 29 30\item{label}{Either a vector object of length \code{x * y} that provides optional 31labels for the new nodes, or, a logical value where setting to \code{TRUE} 32ascribes node IDs to the label and \code{FALSE} yields a blank label.} 33 34\item{rel}{An optional string for providing a relationship label to all new 35edges created in the grid.} 36 37\item{node_aes}{An optional list of named vectors comprising node aesthetic 38attributes. The helper function \code{\link[=node_aes]{node_aes()}} is strongly recommended for 39use here as it contains arguments for each of the accepted node aesthetic 40attributes (e.g., \code{shape}, \code{style}, \code{color}, \code{fillcolor}).} 41 42\item{edge_aes}{An optional list of named vectors comprising edge aesthetic 43attributes. The helper function \code{\link[=edge_aes]{edge_aes()}} is strongly recommended for 44use here as it contains arguments for each of the accepted edge aesthetic 45attributes (e.g., \code{shape}, \code{style}, \code{penwidth}, \code{color}).} 46 47\item{node_data}{An optional list of named vectors comprising node data 48attributes. The helper function \code{\link[=node_data]{node_data()}} is strongly recommended for 49use here as it helps bind data specifically to the created nodes.} 50 51\item{edge_data}{An optional list of named vectors comprising edge data 52attributes. The helper function \code{\link[=edge_data]{edge_data()}} is strongly recommended for 53use here as it helps bind data specifically to the created edges.} 54} 55\value{ 56A graph object of class \code{dgr_graph}. 57} 58\description{ 59With a graph object of class \code{dgr_graph}, add a two-dimensional grid to the 60graph. 61} 62\examples{ 63# Create a new graph and add 64# a 3 x 3 grid 65graph <- 66 create_graph() \%>\% 67 add_grid_2d( 68 x = 3, y = 3, 69 type = "grid") 70 71# Get node information 72# from this graph 73graph \%>\% 74 get_node_info() 75 76# Attributes can be specified 77# in extra arguments and these 78# are applied in order; Usually 79# these attributes are applied 80# to nodes (e.g., `type` is a 81# node attribute) but the `rel` 82# attribute will apply to the 83# edges 84graph_w_attrs <- 85 create_graph() \%>\% 86 add_grid_2d( 87 x = 3, y = 2, 88 label = c("one", "two", 89 "three", "four", 90 "five", "six"), 91 type = c("a", "a", 92 "b", "b", 93 "c", "c"), 94 rel = "grid", 95 node_data = node_data( 96 value = c( 97 1.2, 8.4, 3.4, 98 5.2, 6.1, 2.6))) 99 100# Get the graph's node data frame 101graph_w_attrs \%>\% get_node_df() 102 103# Get the graph's edge data frame 104graph_w_attrs \%>\% get_edge_df() 105 106} 107