Learn R Programming

IVPP (version 1.1.2)

centrality_radar: Radar plot for selected centrality measures

Description

Creates a radar chart (via radarchart) from the output of centrality.

Usage

centrality_radar(
  cent,
  measures = c("outdegree", "indegree", "outEI", "inEI", "bridgestrength",
    "bridgeoutdegree", "bridgeindegree", "bridgebetweenness", "bridgecloseness",
    "bridgeEI_1", "bridgeEI_2"),
  title = NULL,
  axis_range = NULL,
  add_legend = TRUE,
  legend_pos = "bottomright",
  ...
)

Value

Invisibly returns the data frame used for plotting (in fmsb format): the first row is max, the second row is min, and subsequent rows correspond to the requested centrality measures.

Arguments

cent

A list returned by centrality.

measures

Character vector of measures to plot. Allowed values:

  • outdegree, indegree, outEI, inEI

  • bridgestrength, bridgeoutdegree, bridgeindegree, bridgebetweenness, bridgecloseness, bridgeEI_1, bridgeEI_2

title

Optional character title. If provided and ... does not already set title, it is passed to fmsb::radarchart(title = ...).

axis_range

Numeric length-2 vector c(min, max) for the radial axis. If NULL, computed from the selected measures.

add_legend

Logical. If TRUE, adds a base-R legend with one entry per selected measure.

legend_pos

Character position, e.g. "bottomright", "topright", etc.

...

Additional arguments forwarded to radarchart.

See Also

centrality, radarchart

Examples

Run this code
W <- matrix(c(
  0,  0.4, -0.2, 0,
  0.4, 0,   0.1, 0.3,
  -0.2, 0.1, 0,   0.2,
  0,   0.3, 0.2, 0
), nrow = 4, byrow = TRUE)
colnames(W) <- rownames(W) <- c("A", "B", "C", "D")

cent <- centrality(W)

# Plot degree + EI
# pdf('radar_plot.pdf')
centrality_radar(cent, measures = c("outdegree", "outEI"),
                 axis_range = c(0, 1), plwd = 2,
                 seg = 5, caxislabel = seq(0,1,0.2))
# dev.off()

# If bridge metrics were computed:

comm <- c(A="X", B="X", C="Y", D="Y")
cent_b <- centrality(W, communities = comm)
centrality_radar(cent_b, measures = c("bridgestrength", "bridgebetweenness"))

Run the code above in your browser using DataLab