1% Generated by roxygen2: do not edit by hand 2% Please edit documentation in R/mutate_edge_attrs.R 3\name{mutate_edge_attrs} 4\alias{mutate_edge_attrs} 5\title{Mutate a set of edge attribute values} 6\usage{ 7mutate_edge_attrs(graph, ...) 8} 9\arguments{ 10\item{graph}{A graph object of class \code{dgr_graph}.} 11 12\item{...}{Expressions used for the mutation of edge attributes. LHS of each 13expression is either an existing or new edge attribute name. The RHS can 14consist of any valid R code that uses edge attributes as variables. 15Expressions are evaluated in the order provided, so, edge attributes 16created or modified are ready to use in subsequent expressions.} 17} 18\value{ 19A graph object of class \code{dgr_graph}. 20} 21\description{ 22Within a graph's internal edge data frame (edf), mutate numeric edge 23attribute values using one or more expressions. 24} 25\examples{ 26# Create a graph with 3 edges 27graph <- 28 create_graph() \%>\% 29 add_path(n = 4) \%>\% 30 set_edge_attrs( 31 edge_attr = width, 32 values = c(3.4, 2.3, 7.2)) 33 34# Get the graph's internal edf 35# to show which edge attributes 36# are available 37graph \%>\% get_edge_df() 38 39# Mutate the `width` edge 40# attribute, dividing each 41# value by 2 42graph <- 43 graph \%>\% 44 mutate_edge_attrs( 45 width = width / 2) 46 47# Get the graph's internal 48# edf to show that the edge 49# attribute `width` had its 50# values changed 51graph \%>\% get_edge_df() 52 53# Create a new edge attribute, 54# called `length`, that is the 55# log of values in `width` plus 56# 2 (and, also, round all values 57# to 2 decimal places) 58graph <- 59 graph \%>\% 60 mutate_edge_attrs( 61 length = (log(width) + 2) \%>\% 62 round(2)) 63 64# Get the graph's internal edf 65# to show that the edge attribute 66# values had been mutated 67graph \%>\% get_edge_df() 68 69# Create a new edge attribute 70# called `area`, which is the 71# product of the `width` and 72# `length` attributes 73graph <- 74 graph \%>\% 75 mutate_edge_attrs( 76 area = width * length) 77 78# Get the graph's internal edf 79# to show that the edge attribute 80# values had been multiplied 81# together (with new attr `area`) 82graph \%>\% get_edge_df() 83 84} 85\seealso{ 86Other Edge creation and removal: 87\code{\link{add_edge_clone}()}, 88\code{\link{add_edge_df}()}, 89\code{\link{add_edges_from_table}()}, 90\code{\link{add_edges_w_string}()}, 91\code{\link{add_edge}()}, 92\code{\link{add_forward_edges_ws}()}, 93\code{\link{add_reverse_edges_ws}()}, 94\code{\link{copy_edge_attrs}()}, 95\code{\link{create_edge_df}()}, 96\code{\link{delete_edges_ws}()}, 97\code{\link{delete_edge}()}, 98\code{\link{delete_loop_edges_ws}()}, 99\code{\link{drop_edge_attrs}()}, 100\code{\link{edge_data}()}, 101\code{\link{join_edge_attrs}()}, 102\code{\link{mutate_edge_attrs_ws}()}, 103\code{\link{recode_edge_attrs}()}, 104\code{\link{rename_edge_attrs}()}, 105\code{\link{rescale_edge_attrs}()}, 106\code{\link{rev_edge_dir_ws}()}, 107\code{\link{rev_edge_dir}()}, 108\code{\link{set_edge_attr_to_display}()}, 109\code{\link{set_edge_attrs_ws}()}, 110\code{\link{set_edge_attrs}()} 111} 112\concept{Edge creation and removal} 113