Skip to contents

Usage

ggsegmentedtotalbar(
  data,
  x_var,
  y_var,
  fill_var,
  facet_var = NULL,
  chart_style = "clean",
  color_palette = "clinical",
  show_percentages = TRUE,
  percentage_format = "integer",
  show_counts = FALSE,
  label_threshold = 5,
  orientation = "vertical",
  sort_categories = "none",
  plot_title = "",
  x_title = "",
  y_title = "Percentage",
  legend_title = "",
  legend_position = "right",
  bar_width = 0.8,
  plot_width = 10,
  plot_height = 6,
  add_outline = TRUE,
  outline_color = "white",
  export_ready = TRUE
)

Arguments

data

The data as a data frame.

x_var

Categorical variable for x-axis categories.

y_var

Numeric variable for segment values.

fill_var

Categorical variable for bar segment colors and composition.

facet_var

Optional variable for creating multiple panels.

chart_style

Overall visual style for the chart.

color_palette

Color palette for segment fills.

show_percentages

Whether to display percentage labels on segments.

percentage_format

Format for percentage display.

show_counts

Whether to display raw count values on segments.

label_threshold

Minimum percentage for showing labels (0-50\

orientationOrientation of the bars.

sort_categoriesHow to sort the categories.

plot_titleMain title for the plot.

x_titleTitle for x-axis.

y_titleTitle for y-axis.

legend_titleTitle for the legend.

legend_positionPosition of the legend.

bar_widthWidth of the bars (0.1 to 1.0).

plot_widthWidth of the plot in inches.

plot_heightHeight of the plot in inches.

add_outlineWhether to add white outlines around segments.

outline_colorColor for segment outlines.

export_readyWhether to optimize plot for high-quality export.

A results object containing:

results$instructionsa html
results$plotan image
results$summarya table
results$composition_tablea table
results$detailed_statsa table
results$interpretationa html
Tables can be converted to data frames with asDF or as.data.frame. For example:results$summary$asDFas.data.frame(results$summary) Create segmented total bar charts (100\ proportional breakdowns within categories. Perfect for displaying composition data where each bar represents 100\