Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/mergeCommunities.R

Adjust the resolution of a graph-based community detection algorithm by greedily merging clusters together. At each step, the pair of clusters that yield the highest modularity are merged.

1 | ```
mergeCommunities(graph, clusters, number = NULL, steps = NULL)
``` |

`graph` |
A graph object from igraph, usually where each node represents an observation. |

`clusters` |
Factor specifying the cluster identity for each node. |

`number` |
Integer scalar specifying the number of clusters to obtain.
Ignored if |

`steps` |
Integer scalar specifying the number of merge steps. |

This function is similar to the `cut_at`

function from the igraph package,
but works on clusters that were not generated by a hierarchical algorithm.
The aim is to facilitate rapid adjustment of the number of clusters without having to repeat the clustering -
or, even worse, repeating the graph construction, e.g., in `makeSNNGraph`

.

A vector or factor of the same length as `clusters`

,
containing the desired number of merged clusters.

Aaron Lun

`cut_at`

, for a faster and more natural adjustment when using a hierarchical community detection algorithm.

NNGraphParam, for a one-liner to generate graph-based clusters.

1 2 3 4 5 | ```
output <- clusterRows(iris[,1:4], NNGraphParam(k=5), full=TRUE)
table(output$clusters)
merged <- mergeCommunities(output$objects$graph, output$clusters, number=3)
table(merged)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.