Description Usage Arguments Details Value Examples
This method assigns metadata to vertices in an igraph object based on an existing vertex attibute, typically vertex name, but can be done with other attributes including those assigned with previous calls with this method.
1 2 3 4 5 6 7 8 9 10 | Assign_Vmetadata(x, V_metadata, match_attr = NULL,
V_match_attr = "name", reassign = T)
## S4 method for signature 'rnetBasic'
Assign_Vmetadata(x, V_metadata, match_attr = NULL,
V_match_attr = "name", reassign = T)
## S4 method for signature 'rnetStrata'
Assign_Vmetadata(x, V_metadata, match_attr = NULL,
V_match_attr = "name", reassign = T)
|
x |
The network to which the vertex metadata will be applied. |
V_metadata |
A dataframe containing the vertex metadata to be assigned. A vertex attribute will be assigned for every column in the frame, except the column used to match V_metadata to existing vertex attribues. |
match_attr |
The name of the column in V_metadata used to match metadata to vertices. Defaults to the first column of V_metadata. |
V_match_attr |
the name of the vertex attribute used to match metadata. Defaults to 'name' (V(x)$name), which is typically assigned when the network is created with igraph functions. |
reassign |
A logical argument controling if the function should overwrite x in the parent environment. Defaults to 'True' for brevity. |
This method also works with all rnet objects (currently class 'rnetBasic', 'rnetStrata', and 'rnet.multi.strata'), and also adds the names of the metadata attributes to the 'V_metadata' slot.
An object of the same type as x, with the new vertex attributes assigned by matching 'match_attr' to 'V_match_attr'.
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 | # V_ATTRS' is a data.frame included in the package containing vertex metadata
# regarding antimicrobial class and a color scheme for the vertices. These
# attributes are useful for plotting and determining modularity.
ABX_LIST <- c('AMP', 'AMC', 'AXO', 'TIO', 'NAL', 'CIP', 'STR', 'GEN', 'COT', 'FIS')
EC08_rnet <- Rnet(NARMS_EC_DATA,
L1 = 0.25,
vertices = ABX_LIST,
subset = NARMS_EC_DATA$Year == 2008
)
#Attributes prior to additions
vertex_attr_names(EC08_rnet@R)
vertex_attr(EC08_rnet@R)
Assign_Vmetadata(EC08_rnet,
V_metadata = V_ATTRS,
match_attr = 'Code',
V_match_attr = 'name'
)
#NOTE: EC08_rnet does not need to be reassigned for brevity. Returns data.frame of assigned data.
# Reassignment can be performed, if desired. data.frame not returned in such a case.
EC08_withAttrs <- Assign_Vmetadata(EC08_rnet,
V_metadata = V_ATTRS,
match_attr = 'Code',
V_match_attr = 'name'
)
#Atrributes after edges assigned.
vertex_attr(EC08_rnet@R)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.