Skip to content

New Functions in waffle-plot-dev Branch#6

Merged
CarwilB merged 14 commits into
mainfrom
waffle-plot-dev
Oct 30, 2025
Merged

New Functions in waffle-plot-dev Branch#6
CarwilB merged 14 commits into
mainfrom
waffle-plot-dev

Conversation

@CarwilB

@CarwilB CarwilB commented Oct 30, 2025

Copy link
Copy Markdown
Member

Based on the comparison with the main branch, here are the new functions added:

Waffle Chart Functions (R/waffle-plot-functions.R)

  1. waffle_counts() - Helper function to create counts dataframe for waffle charts

    • Filters and counts data by x_var and fill_var combinations
    • Ensures proper factoring of fill variable
  2. complete_x_values() - Adds null/missing x values to counts

    • Fills gaps in year or pres_admin sequences with white placeholder blocks
    • Supports both year (numeric) and pres_admin (factor) variables
  3. make_waffle_chart() - Creates horizontal waffle charts with facets

    • Main function for creating waffle visualizations
    • Parameters: dataframe, x_var, fill_var, fill_var_description, n_columns, waffle_width
    • Supports complete_x to fill missing values
    • Supports lang parameter ("en" or "es") for Spanish legend labels
  4. make_waffle_chart_tall() - Creates vertical/tall waffle charts

    • Similar to make_waffle_chart() but with vertical orientation
    • Facets arranged in rows instead of columns
    • Also supports complete_x and lang parameters

Variable Description Sorting Functions (R/sort-var-description.R)

  1. sorted_by_widest_appearance() - Sorts variable descriptions by how widely levels appear across groups

    • Example: Sort protest domains by how many presidential administrations they appear in
    • Reorders levels, levels_es, colors, and colors_es to match
  2. sorted_by_most_frequent() - Sorts variable descriptions by frequency

    • Reorders based on total count of each level
    • Also preserves Spanish translations and colors

Presidential Administration Function (R/relabel-pres-admin.R)

  1. relabel_pres_admin() - Relabels pres_admin using presidency_name_table
    • Allows switching between different name formats (presidency_year, presidency_initials, etc.)
    • Parameters: dataframe, output_column, .input_column, keep_original
    • Automatically factors the result in the correct order

Filename Utilities (R/filename-tools-subset.R)

  1. domain_filename() - Generates protest domain filename paths

    • Creates relative URLs like /domain/rural-land.html
    • Returns empty string for overlapping domains (with commas)
  2. domain_filename_es() - Generates Spanish domain filename paths

    • Creates Spanish URLs like /dominio/campesino.html

Additional Changes

  • Added ggplot2 and waffle package dependencies
  • Updated variable description lists with title_es fields for Spanish titles
  • Changed state responsibility "Victim" color from #cd6600 (darkorange3) to #8B1A1A (firebrick4)
  • Comprehensive test coverage added for all new functions
  • Package version bumped to 0.0.0.9011

All functions include proper roxygen2 documentation, examples, and testthat unit tests.

@CarwilB
CarwilB merged commit d4ad770 into main Oct 30, 2025
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant