hgch_bar: Highcharter Bar Chart

hgch_barR Documentation

Highcharter Bar Chart

Description

Creates a bar chart using Highcharter library.

Usage

hgch_bar(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 bar 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_bar(mtcars, var_cat = "cyl", var_num = "mpg")


### Adding style to plots
ops <- list(titles = list(title = "title",
                          subtitle = "subtitle",
                          caption = "caption"))

 data <- ggplot2::diamonds |>
   dplyr::select(cut, color, price, everything())

 # plot 1
 hgch_bar_CatCat(data, opts = ops)

 # plot 2
 hgch_bar_CatCatNum(data, opts = ops)


 # opts from theme (canvas)
 test_theme <- list(
   theme = list(
   background_color = "#2f2f2f",
   plot_margin_bottom = 30,
   plot_margin_left = 30,
   plot_margin_right = 30,
   plot_margin_top = 30,
   plot_background_color = "#f2f2f2",
   plot_border_color = "#ff2c2f",
   plot_border_size = 3,
   text_family = "ubuntu",
   text_size = 15
   )
 )

 data <- ggplot2::diamonds |>
  dplyr::select(cut, everything())

hgch_bar_Cat(data, opts = test_theme)


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