create_waffle_chart: create_waffle_chart

View source: R/create_waffle_chart.R

create_waffle_chartR Documentation

create_waffle_chart

Description

Function creates a "waffle" chart that displays percentages for multiple variables. The chart is similar to a heatmap with a 10 by 10 array of tiles (each representing one percent) that are colored to the extent of the variable's proportion value. For more information on "waffle" charts see What is a waffle chart.

Usage

create_waffle_chart(
  x = NULL,
  name_col = NULL,
  prop_col = NULL,
  title = NULL,
  select_fill = "brown",
  default_fill = "lightgray"
)

Arguments

x

Either a dataframe or a vector of named integer proportions.

name_col

If 'x' is a dataframe, a required string setting the column name having the variable names.

prop_col

If 'x' is a dataframe, a required string setting the column name having the variable proportions.

title

A string that sets the main title for the chart.

select_fill

A string that sets the fill color for tiles with proportion values.

default_fill

A string that sets the fill color for tiles without proportion values.

Value

A ggplot2 class object

Examples

library(grid)
library(gtable)
library(ggplotify)
library(ggplot2)
library(RplotterPkg)

proportions_v <- c(
var1=10,var2=40,var3=20, var4=50, var5=5,
var6=30, var7=10, var8=67, var9=42, var10=33,
var11=7, var12=35,var13=22, var14=90
)
create_waffle_chart(
  x = proportions_v,
  title = "Test For 14 Proportion Variables"
)


deandevl/RplotterPkg documentation built on March 1, 2025, 11:17 a.m.