Description Usage Arguments Value Examples
The attribute reporting the aggregated weight of the multiedges is computed according to the expression specified in 'aggr_expression'. When no expression is specified, the 'attr' column returns the multiedge multiplicity.
1 | multi2weight(edge.list, select_cols = NULL, aggr_expression = NULL)
|
edge.list |
dataframe containing a (weighted) edgelist. |
select_cols |
optional vector of 2 elements specifying which columns are the source,target for the edges from which building the weighted edge list. Otherwise column 1 is assumed to be the source and column 2 the target. |
aggr_expression |
string, the expression used to compute the aggregated
value in the adjacency matrix in the presence of multiedges. It defaults to
' |
a tibble with 3 columns: source, target, and attr, where attr has been computed according to 'aggr_expression'.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | el <- data.frame(from= c('a','b','b','c','d','d','d','d'),
to = c('b','c','d','a','b','a','a','a'),
attr= c( 1, 1, 1 , 1 , 1 , 1, 2 , 3 ),
attr2= c( TRUE, FALSE, TRUE , TRUE , FALSE , TRUE, TRUE , FALSE ))
# edgelist with multiedge multiplicities
multi2weight(el)
# edgelist with sum of attr
multi2weight(el, aggr_expression='sum(attr)')
# edgelist with mean of attr
multi2weight(el, aggr_expression='mean(attr)')
# edgelist with min of attr
multi2weight(el, aggr_expression='min(attr)')
# edgelist with max of attr
multi2weight(el, aggr_expression='max(attr)')
# edgelist with any() of attr2
multi2weight(el, aggr_expression='any(attr2)')
# edgelist with all() of attr2
multi2weight(el, aggr_expression='all(attr2)')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.