gt_plt_bar | R Documentation |
gt
tableThe gt_plt_bar
function takes an existing gt_tbl
object and
adds horizontal barplots via ggplot2
. Note that values are plotted on a
shared x-axis, and a vertical black bar is added at x = zero. To add labels
to each of the of the bars, set scale_type
to either 'percent'
or 'number
'.
gt_plt_bar(
gt_object,
column = NULL,
color = "purple",
...,
keep_column = FALSE,
width = 40,
scale_type = "none",
text_color = "white"
)
gt_object |
An existing gt table object of class |
column |
A single column wherein the bar plot should replace existing data. |
color |
A character representing the color for the bar, defaults to purple. Accepts a named color (eg |
... |
Additional arguments passed to |
keep_column |
|
width |
An integer indicating the width of the plot in pixels. |
scale_type |
A string indicating additional text formatting and the addition of numeric labels to the plotted bars if not |
text_color |
A string indicating the color of text if |
An object of class gt_tbl
.
library(gt) gt_plt_bar_tab <- mtcars %>% head() %>% gt() %>% gt_plt_bar(column = mpg, keep_column = TRUE)
3-4
Other Plotting:
gt_plt_bar_pct()
,
gt_plt_bar_stack()
,
gt_plt_dist()
,
gt_plt_percentile()
,
gt_plt_point()
,
gt_plt_sparkline()
,
gt_plt_winloss()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.