hgch_sankey: Highcharter sankey Chart

hgch_sankeyR Documentation

Highcharter sankey Chart

Description

Creates a sankey chart using Highcharter library.

Usage

hgch_sankey(data, dic = NULL, var_cat = NULL, var_num = NULL, ...)

Arguments

data

a data frame containing the variables to be plotted.

dic

a named list, each element corresponding to a column name in data and defining a set of labels for that column.

var_cat

the names of the categorical variables in the data frame

var_num

a character vector with the name of numerical variable.

...

additional arguments to be passed to dsviz_default_opts

Value

a Highcharter sankey chart.

See Also

data_draw

Examples

data <- ggplot2::diamonds
data <- data |>
  dplyr::group_by(cut, clarity) |>
  dplyr::summarise(total = sum(z, na.rm = T))

hgch_sankey(data, var_cat = c("cut", "clarity"), var_num = "total")

### Adding style to plot
test_theme <- list(
  theme = list(
    palette_colors = "#ffa92a",
    caption_align = "right",
    caption_family = "Roboto",
    caption_size = 15,
    caption_color = "#3b83b8",
    caption_weight = 700
  )
)

data <- dplyr::starwars
data <- data |>
  dplyr::select(hair_color, sex) |>
  tidyr::drop_na()

hgch_sankey_CatCat(data,
                   opts = test_theme,
                   caption = "theme caption")


randommonkey/hgchmagic documentation built on Aug. 23, 2023, 5:56 a.m.