graph: Graph

e_graphR Documentation

Graph

Description

Create a graph.

Usage

e_graph(e, layout = "force", name = NULL, rm_x = TRUE, rm_y = TRUE, ...)

e_graph_gl(
  e,
  layout = "force",
  name = NULL,
  rm_x = TRUE,
  rm_y = TRUE,
  ...,
  itemStyle = list(opacity = 1)
)

e_graph_nodes(
  e,
  nodes,
  names,
  value,
  size,
  category,
  symbol = NULL,
  legend = TRUE
)

e_graph_edges(e, edges, source, target, value, size)

Arguments

e

An echarts4 object as returned by e_charts.

layout

Layout, one of force, none or circular.

name

Name of graph.

rm_x, rm_y

Whether to remove the x and y axis, defaults to TRUE.

...

Any other parameter.

itemStyle

This option is available for for GL and canvas graph but is only necessary for GL.

nodes

Data.frame of nodes.

names

Names of nodes, unique.

value

Values of nodes or edges.

size

Sizes of nodes or edges.

category

Group of nodes (i.e.: group membership).

symbol

Symbols of nodes.

legend

Whether to add serie to legend.

edges

Data.frame of edges.

source, target

Column names of source and target.

See Also

Additional arguments, e_modularity

Examples

value <- rnorm(10, 10, 2)

nodes <- data.frame(
  name = sample(LETTERS, 10),
  value = value,
  size = value,
  symbol = sample(c("circle", "rect", "triangle"), 10, replace = TRUE),
  grp = rep(c("grp1", "grp2"), 5),
  stringsAsFactors = FALSE
)

value_edges <- sample(1:100, 20, replace = TRUE)
edges <- data.frame(
  source = sample(nodes$name, 20, replace = TRUE),
  target = sample(nodes$name, 20, replace = TRUE),
  value = value_edges,
  size = ceiling(value_edges/20),
  stringsAsFactors = FALSE
)

e_charts() |>
  e_graph() |>
  e_graph_nodes(nodes, name, value, size, grp, symbol) |>
  e_graph_edges(edges, source, target, value, size) |>
  e_tooltip()

# Use graphGL for larger networks
nodes <- data.frame(
  name = paste0(LETTERS, 1:1000),
  value = rnorm(1000, 10, 2),
  size = rnorm(1000, 10, 2),
  grp = rep(c("grp1", "grp2"), 500),
  stringsAsFactors = FALSE
)

edges <- data.frame(
  source = sample(nodes$name, 2000, replace = TRUE),
  target = sample(nodes$name, 2000, replace = TRUE),
  stringsAsFactors = FALSE
)

e_charts() |>
  e_graph_gl() |>
  e_graph_nodes(nodes, name, value, size, grp) |>
  e_graph_edges(edges, source, target)

echarts4r documentation built on July 9, 2023, 7:26 p.m.