`r lifecycle::badge("stable")` Simple function to visualize paired circumplex data by drawing lines between two matched observations. Useful for showing movement or differences across two conditions (e.g., same pieces by different groups).
plot_paired_scatterplot(
data,
x,
y,
group,
group_levels,
label,
id_by_shape = FALSE,
id_by_text = FALSE
)Tibble or data.frame object containing paired observations.
Character. Column name for x variable. Should be passed as a string.
Character. Column name for y variable. Should be passed as a string.
Character. Column name denoting grouping variable with at least two levels. Should be passed as a string.
Character vector of length 2. Names of the two levels within `group` to compare.
Character. Column name of labels for each matched observation (e.g., "pieceID").
Boolean. Option to distinguish group levels by shape in the plot; FALSE by default.
Boolean. Option to add text labels for both groups; TRUE by default.
NULL.
# Set up data.
dfs <- subset(
df_emosample,
expID %in% c(101, 135)
)
dfs <- dfs |>
dplyr::group_by(expID, pieceID) |>
dplyr::mutate(
valence = mean(valence, na.rm = TRUE),
arousal = mean(arousal, na.rm = TRUE)
) |>
dplyr::select(expID, pieceID, valence, arousal) |>
dplyr::distinct()
#
plot_paired_scatterplot(
data = dfs,
x = "valence",
y = "arousal",
group = "expID",
group_levels = c(101, 135),
label = "pieceID"
)
#
plot_paired_scatterplot(
data = dfs,
x = "valence",
y = "arousal",
group = "expID",
group_levels = c(101, 135),
label = "pieceID",
id_by_text = TRUE
)
#
plot_paired_scatterplot(
data = dfs,
x = "valence",
y = "arousal",
group = "expID",
group_levels = c(101, 135),
label = "pieceID",
id_by_shape = TRUE
)