Skip to contents

These functions help you quickly create interactive hierarchical plots from categorical data. They expect the summary of the data created by dplyr::count() and produce either a sunburst plot (plotSunburst()) or a treemap plot (plotTreemap())

Usage

plotSunburst(count_data, fill_by_n = FALSE, sort_by_n = FALSE, maxdepth = 2)

plotTreemap(count_data, fill_by_n = FALSE, sort_by_n = FALSE)

Arguments

count_data

A data frame containing the data.

fill_by_n

Logical indicating if fill color is based on counts.

sort_by_n

Logical indicating if data should be sorted by counts.

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
starwars_count <- count(starwars, species, eye_color, name)

# sunburst plot
plotSunburst(starwars_count)
# fill by group size plotSunburst(starwars_count, fill_by_n = TRUE)
# treemap plot, ordered by group size plotTreemap(starwars_count, sort_by_n = TRUE)
# display al charchaters by homeworld starwars %>% count(homeworld, name) %>% plotTreemap(sort_by_n = TRUE)