Type: Package
Title: Utilities and Helpers for Single Case Experimental Design (SCED) using 'ggplot2'
Version: 0.1.6
Description: Provides specialized visualization tools for Single-Case Experimental Design (SCED) research using 'ggplot2'. SCED studies are a crucial methodology in behavioral and educational research where individual participants serve as their own controls through carefully designed experimental phases. This package extends 'ggplot2' to create publication-ready graphics with professional phase change lines, support for multiple baseline designs, and styling functions that follow SCED visualization conventions. Key functions include adding phase change demarcation lines to existing plots and formatting axes with broken axis appearance commonly used in single-case research.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Encoding: UTF-8
LazyData: true
Depends: ggplot2, ggh4x, R (≥ 3.5.0)
Imports: grid, gtable, assert
Suggests: knitr, rmarkdown, testthat (≥ 3.0.0), usethis, tidyverse
RoxygenNote: 7.2.3
Config/testthat/edition: 3
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2026-01-16 12:49:03 UTC; shawn
Author: Shawn Gilroy ORCID iD [aut, cre, cph]
Maintainer: Shawn Gilroy <sgilroy1@lsu.edu>
Repository: CRAN
Date/Publication: 2026-01-21 20:10:14 UTC

Plotting data from Gilroy et al. (2015)

Description

This is data either extracted or included (with permission) to assist with illustrating and replicating the functionality of the package. Specifically, this data is used to illustrate conventions regarding a multiple probe design and how that may be constructed in this package.

Usage

Gilroyetal2015

Format

A data frame with 40 rows and 6 variables:

Participant

Participant name

Session

Session number

Condition

Condition name

Responding

Responding rates

PhaseNum

Phase number

LineOff

Offset for phase line

Source

<doi:https://doi.org/10.1016/j.rasd.2015.04.004>


Plotting data from Gilroy et al. (2021)

Description

Treatment data from Gilroy et al. (2021)

Usage

Gilroyetal2021

Format

A data frame with 69 rows and 7 variables:

Participant

Participant name

Session

Session number

Condition

Functional analysis condition

Responding

Rates of responding

Reinforcers

Reinforcer deliveries

PhaseNum

Sequenced phase number

LineOff

Offset of phase line

Source

<doi:https://doi.org/10.1002/jaba.826>


ggsced

Description

Core exported function to facilitate the drawing of phase change lines atop a ggplot object. Primarily designed to be used *after* the plot is finalized, with the lines being the last element drawn at the highest z index (i.e., atop all elements).

Usage

ggsced(plt, legs, offs = NULL, print = TRUE, verbose = FALSE)

Arguments

plt

ggplot object as typically designed/printed in userspace

legs

list of 'legs' to be drawn

offs

mapping of lines that require minor offset

print

output result directly to graphical device (default = TRUE)

verbose

Optional ability to view process output (debugging primarily)

Value

Finalized figure with respective phase change lines embedded.


generate_condition_labels

Description

Optional helper class to prepare condition labels (e.g., Baseline, Intervention) based on the grouping of an existing ggplot object

Usage

ggsced_condition_labels(plt, y = NULL)

Arguments

plt

ggplot object

y

ordinate of respective label (Default = last tick from plot object)

Value

a data frame that can be used with a geom_text layer


ggsced_extract_domain

Description

Internal helper to pull respective panel parameters and assert validity.

Usage

ggsced_extract_domain(panel_params)

Arguments

panel_params

respective parameters of panel grob

Value

numeric vector specifying size in min-max units


ggsced_facet_labels

Description

Optional helper class to prepare facet labels (e.g., Participant names) based on the faceting of an existing ggplot object

Usage

ggsced_facet_labels(plt, y = 0, x = NULL)

Arguments

plt

ggplot object

y

ordinate of respective label (typically very low or very high)

x

position on the x-axis (Default = last tick from plot object)

Value

a data frame that can be used with a geom_text layer


ggsced_get_panels

Description

Honestly, a bit of a 'hackish' solution to extract grobs that are associated with data to be drawn. Probably fragile and specific to modern gg implementations, but probably the close we'll get. Subject to change.

Usage

ggsced_get_panels(ggplot_grobs)

Arguments

ggplot_grobs

list of grobs prepared by ggplotGrob

Value

filtered list of grobs restricted to faceted levels


ggsced_internal_x_axis

Description

Internal helper class to draw a conventional x-axis per SCED publication suggestions.

Usage

ggsced_internal_x_axis(expansion = 0, lwd = 2, col = "black")

Arguments

expansion

Percentage of axis to pad (left/right) to break axis (Note: normalized parent units)

lwd

Width of axis line

col

Color of axis drawn (default = 'black')

Value

Rendering of customized x axis across facets


ggsced_internal_y_axis

Description

Internal helper class to draw a conventional y-axis per SCED publication suggestions.

Usage

ggsced_internal_y_axis(expansion = 0, lwd = 2, col = "black")

Arguments

expansion

Percentage of axis to pad (top/bottom) to break axis (Note: normalized parent units)

lwd

Width of axis line

col

Color of axis drawn (default = 'black')

Value

Rendering of customized y axis across facets


ggsced_name_dogleg

Description

Grobs need to have unique names lest they get accidentally overwritten. This is a convenience naming function for the 'main' phase break within a facet level.

Usage

ggsced_name_dogleg(panel, index, n_leg)

Arguments

panel

name of the parent grob

index

index of the phase change in sequence

n_leg

leg in the phase change

Value

a name corresponding with unique phase-change grob element


ggsced_name_dogleg_lateral

Description

Grobs need to have unique names lest they get accidentally overwritten. This is a convenience naming function for the 'lateral' part of a phase break within a facet level.

Usage

ggsced_name_dogleg_lateral(panel, index, n_leg)

Arguments

panel

name of the parent grob

index

index of the phase change in sequence

n_leg

leg in the phase change

Value

a name corresponding with unique phase-change grob element


ggsced_output_console

Description

Optional output function to support debugging (mainly for testing)

Usage

ggsced_output_console(msg, output)

Arguments

msg

Message to be output to console

output

Boolean to discern whether or not to output message


ggsced_scale_units

Description

Internal helper to discern exactly where a vertical would need to be placed within a specific grob (i.e., panel grob). Uses the domain and phase change location as a reference to convert to npc units for gtable and grid.

Usage

ggsced_scale_units(session_value, domain_size)

Arguments

session_value

Session associated with phase-change line

domain_size

Total size of domain per panel specification

Value

A proportional value given value in a panel domain


ggsced_style_x

Description

This is a convenience element designed to support a more complete interpretation of SCED-specific style conventions through ggplot. Specifically, an axis is drawn with a specific manner of expansion to support the broken axis (i.e., non-connected x/y) expected of SCED-specific publication guidelines.

Usage

ggsced_style_x(expansion = 0, lwd = 2, col = "black")

Arguments

expansion

Percentage of axis to pad (left/right) to break axis (Note: normalized parent units)

lwd

Width of axis line

col

Color of axis drawn (default = 'black')

Value

Annotation to simulate a disconnected y-axis via expansion


ggsced_style_y

Description

This is a convenience element designed to support a more complete interpretation of SCED-specific style conventions through ggplot. Specifically, an axis is drawn with a specific manner of expansion to support the broken axis (i.e., non-connected x/y) expected of SCED-specific publication guidelines.

Usage

ggsced_style_y(expansion = 0, lwd = 2, col = "black")

Arguments

expansion

Percentage of axis to pad (top/bottom) to break axis (Note: normalized parent units)

lwd

Width of axis line

col

Color of axis drawn (default = 'black')

Value

Annotation to simulate a disconnected y-axis via expansion


sced_phase_change_complex_lateral_grob

Description

This is a helper class to standardize drawing grobs

Usage

sced_phase_change_complex_lateral_grob(x0, x1, segment_name)

Arguments

x0

value corresponding to respective domain in npc units

x1

value corresponding to respective domain in npc units

segment_name

name associated with object

Value

graphical object


sced_phase_change_complex_lateral_post_grob

Description

This is a helper class to standardize drawing grobs

Usage

sced_phase_change_complex_lateral_post_grob(x, segment_name)

Arguments

x

value corresponding to respective domain in npc units

segment_name

name associated with object

Value

graphical object


sced_phase_change_complex_lateral_pre_grob

Description

This is a helper class to standardize drawing grobs

Usage

sced_phase_change_complex_lateral_pre_grob(x, segment_name)

Arguments

x

value corresponding to respective domain in npc units

segment_name

name associated with object

Value

graphical object


sced_phase_change_main_panel_grob

Description

This is a helper class to standardize drawing grobs

Usage

sced_phase_change_main_panel_grob(x, segment_name)

Arguments

x

value corresponding to respective domain in npc units

segment_name

name associated with object

Value

graphical object


sced_phase_change_simple_lateral_grob

Description

This is a helper class to standardize drawing grobs

Usage

sced_phase_change_simple_lateral_grob(x0, x1, segment_name)

Arguments

x0

value corresponding to respective domain in npc units

x1

value corresponding to respective domain in npc units

segment_name

name associated with object

Value

graphical object

mirror server hosted at Truenetwork, Russian Federation.