1% Generated by roxygen2: do not edit by hand
2% Please edit documentation in R/copy_node_attrs.R
3\name{copy_node_attrs}
4\alias{copy_node_attrs}
5\title{Copy a node attribute column and set the name}
6\usage{
7copy_node_attrs(graph, node_attr_from, node_attr_to)
8}
9\arguments{
10\item{graph}{A graph object of class \code{dgr_graph}.}
11
12\item{node_attr_from}{The name of the node attribute column from which values
13will be copied.}
14
15\item{node_attr_to}{The name of the new node attribute column to which the
16copied values will be placed.}
17}
18\value{
19A graph object of class \code{dgr_graph}.
20}
21\description{
22Within a graph's internal node data frame (ndf), copy the contents an
23existing node attribute and create a distinct node attribute within the ndf
24with a different attribute name.
25}
26\examples{
27# Create a random graph using the
28# `add_gnm_graph()` function
29graph <-
30  create_graph() \%>\%
31  add_gnm_graph(
32    n = 5,
33    m = 10,
34    set_seed = 23) \%>\%
35  set_node_attrs(
36    node_attr = shape,
37    values = "circle") \%>\%
38  set_node_attrs(
39    node_attr = value,
40    values = rnorm(
41      n = count_nodes(.),
42      mean = 5,
43      sd = 1) \%>\% round(1))
44
45# Get the graph's internal
46# ndf to show which node
47# attributes are available
48graph \%>\% get_node_df()
49
50# Make a copy the `value`
51# node attribute as the
52# `width` node attribute
53graph <-
54  graph \%>\%
55  copy_node_attrs(
56    node_attr_from = value,
57    node_attr_to = size)
58
59# Get the graph's internal
60# ndf to show that the node
61# attribute had been copied
62graph \%>\% get_node_df()
63
64}
65\seealso{
66Other Node creation and removal:
67\code{\link{add_n_node_clones}()},
68\code{\link{add_n_nodes_ws}()},
69\code{\link{add_n_nodes}()},
70\code{\link{add_node_clones_ws}()},
71\code{\link{add_node_df}()},
72\code{\link{add_nodes_from_df_cols}()},
73\code{\link{add_nodes_from_table}()},
74\code{\link{add_node}()},
75\code{\link{colorize_node_attrs}()},
76\code{\link{create_node_df}()},
77\code{\link{delete_nodes_ws}()},
78\code{\link{delete_node}()},
79\code{\link{drop_node_attrs}()},
80\code{\link{join_node_attrs}()},
81\code{\link{layout_nodes_w_string}()},
82\code{\link{mutate_node_attrs_ws}()},
83\code{\link{mutate_node_attrs}()},
84\code{\link{node_data}()},
85\code{\link{recode_node_attrs}()},
86\code{\link{rename_node_attrs}()},
87\code{\link{rescale_node_attrs}()},
88\code{\link{set_node_attr_to_display}()},
89\code{\link{set_node_attr_w_fcn}()},
90\code{\link{set_node_attrs_ws}()},
91\code{\link{set_node_attrs}()},
92\code{\link{set_node_position}()}
93}
94\concept{Node creation and removal}
95