Skip to contents

Creates a horizontal bar plot of code frequencies based on the output of summarize_codes(). Users can optionally plot proportions instead of raw counts, filter by minimum frequency, or exclude specific codes.

Usage

plot_counts(
  df_all_summary,
  plot_proportion = FALSE,
  min_count = NULL,
  min_proportion = NULL,
  exclude_codes = NULL
)

Arguments

df_all_summary

A data frame or tibble containing at least two columns: Code and total_preferred_coder, typically the output from summarize_codes(output_type = "tibble").

plot_proportion

Logical. If TRUE, plots code frequencies as proportions of the total count. Defaults to FALSE (raw counts).

min_count

Integer. Optional. Filters out codes with fewer than this number of occurrences.

min_proportion

Numeric. Optional. Filters out codes with a proportion less than this value (e.g., 0.02).

exclude_codes

Character vector. Optional. Codes to exclude from the plot (e.g., c("Other", "Heterogeneity")).

Value

A ggplot2 object showing a horizontal bar plot of code frequencies or proportions.

Examples

if (FALSE) { # \dontrun{
summary_data <- summarize_codes(my_excerpts, preferred_coders, output_type = "tibble")
plot_counts(summary_data, plot_proportion = TRUE, min_proportion = 0.02)
plot_counts(summary_data, min_count = 30, exclude_codes = c("Other"))
} # }