| getColors | R Documentation | 
The function getColors returns the colors associated to the nodes of
a gGraph object, based on a specified node attribute.
getColors(x, ...)
## S4 method for signature 'gGraph'
getColors(x, nodes = "all", attr.name, col.rules = NULL, ...)
x | 
 a valid gGraph.  | 
... | 
 other arguments passed to other methods.  | 
nodes | 
 a vector of character strings or of integers identifying nodes by their name or their index. Can be "all", in which case all nodes are considered.  | 
attr.name | 
 a character string indicating the name of node attribute to be used to define colors.  | 
col.rules | 
 a matrix giving the rules for plotting attribute values with different colors. See details.  | 
Colors are based on a node attribute, that is, on a column of the
nodes.attr data.frame. This attribute should have a finite number of
values, and would most likely be a factor. Correspondence between values of
this variable and colors must be provided in the @meta\$color slot,
or as col.rules argument. Color rules mus be provided as a two-column
matrix; the first column contains values of a node attribute, and is named
after this attribute; the second must be named "color", and contain valid
colors.
See example section to know how this slot should be designed.
A vector of characters being valid colors.
getColors(gGraph): Method for gGraph objects
worldgraph.10k # there is a node attribute 'habitat'
worldgraph.10k@meta$color
head(getNodes(worldgraph.10k))
head(getColors(worldgraph.10k, res.type = "vector", attr.name = "habitat"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.