gt_plt_bar {gtExtras} | R Documentation |
Add bar plots into rows of a gt
table
Description
The 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
'.
Usage
gt_plt_bar(
gt_object,
column = NULL,
color = "purple",
...,
keep_column = FALSE,
width = 40,
scale_type = "none",
text_color = "white"
)
Arguments
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 |
Value
An object of class gt_tbl
.
Examples
library(gt) gt_plt_bar_tab <- mtcars %>% head() %>% gt() %>% gt_plt_bar(column = mpg, keep_column = TRUE)
Function ID
3-4
See Also
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()