hgch_treemap: Highcharter treemap Chart

hgch_treemapR Documentation

Highcharter treemap Chart

Description

Creates a treemap chart using Highcharter library.

Usage

hgch_treemap(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

a character vector with the names of categorical variables.

var_num

a character vector with the names of numerical variables.

...

additional arguments to be passed to dsviz_default_opts

Value

a Highcharter treemap chart.

See Also

data_draw

Examples

data(mtcars)
mtcars$cyl <- as.character(mtcars$cyl)
mtcars <- mtcars |>
  dplyr::group_by(cyl) |>
  dplyr::summarise(mpg = mean(mpg))

hgch_treemap(mtcars,
             var_cat = "cyl",
             var_num = "mpg")

### Custom labels
data <- ggplot2::diamonds
data <- data |>
  dplyr::group_by(cut) |>
  dplyr::summarise(price_sum = sum(price)),
                                     agg = "sum",
                                     group_var = "cut",
                                     to_agg = "price")

# Define custom layers
ops <- list(title = "title",
            subtitle = "subtitle",
            caption = "caption",
            hor_title = "Categorias",
            ver_title = "Numeros",
            bar_orientation = "hor")

hgch_treemap(data,
             var_cat = "cut",
             var_num = "price_sum",
             opts =  ops)

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