Learn R Programming

diceplot (version 0.1.7)

prepare_box_data: Prepare Box Data

Description

Prepares data for plotting boxes by calculating box boundaries based on category positions.

Usage

prepare_box_data(data, cat_a, cat_b, group, cat_a_order, cat_b_order)

Value

A data frame with box boundaries for plotting.

Arguments

data

A data frame containing the variables.

cat_a

The name of the column representing category A.

cat_b

The name of the column representing category B.

group

The name of the column representing the grouping variable.

cat_a_order

A vector specifying the order of category A.

cat_b_order

A vector specifying the order of category B.

Examples

Run this code
library(dplyr)
data <- data.frame(
  cat_a = rep(letters[1:3], each = 2),
  cat_b = rep(LETTERS[1:2], times = 3),
  group = rep(c("G1", "G2"), times = 3)
)
cat_a_order <- c("a", "b", "c")
cat_b_order <- c("A", "B")
prepare_box_data(data, "cat_a", "cat_b", "group", cat_a_order, cat_b_order)

Run the code above in your browser using DataLab