data_to_hierarchical: Helper to transform data frame for treemap/sunburst...

Description Usage Arguments Examples

View source: R/data-helpers.R

Description

Helper to transform data frame for treemap/sunburst highcharts format

Usage

1
2
3
4
5
6
data_to_hierarchical(
  data,
  group_vars,
  size_var,
  colors = getOption("highcharter.color_palette")
)

Arguments

data

data frame containing variables to organize each level of the treemap.

group_vars

Variables to generate treemap levels.

size_var

Variable to aggregate.

colors

Color to chart every item in the first level.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 

library(dplyr)
data(gapminder, package = "gapminder")

gapminder_2007 <- gapminder::gapminder %>%
  filter(year == max(year)) %>%
  mutate(pop_mm = round(pop / 1e6))

dout <- data_to_hierarchical(gapminder_2007, c(continent, country), pop_mm)

hchart(dout, type = "sunburst")

hchart(dout, type = "treemap")

## End(Not run)

highcharter documentation built on Jan. 3, 2022, 5:08 p.m.