`r lifecycle::badge("stable")` Simple function to prepare a circumplex model based on user input.

plot_circumplex(
  data,
  x,
  y,
  label,
  group,
  yintercept = 50,
  xintercept = 4,
  add_points = FALSE,
  add_text = TRUE,
  ...
)

Arguments

data

Tibble or data.frame object

x

Character. Column name for x variable. Should be passed as a string.

y

Character. Column name for y variable. Should be passed as a string.

label

Character. Labels to add to plot. Should be passed as a string.

group

Character. Column of group to colour-code observations by. Should be passed as a string.

yintercept

Numeric. y intercept defining placement of horizontal line, defaulted to y = 50 as the midpoint for arousal ratings.

xintercept

Numeric. x intercept defining placement of vertical line, defaulted to x = 4 as the midpoint for valence ratings.

add_points

Boolean. Option to add points marking observation; FALSE by default.

add_text

Boolean. Option to add text based on label input; TRUE by default.

...

Additional arguments passed to geom_text.

Examples

# Typical usage.
df <- subset(df_emosample, expID == 101)

df_circumplex <- df |>
  dplyr::group_by(pieceID) |>
  dplyr::mutate(
     valence_mean = mean(valence),
     arousal_mean = mean(arousal)
  ) |>
  dplyr::select(
    setCode,
    albumID,
    pieceID,
    mode,
    valence_mean,
    arousal_mean
  ) |>
  dplyr::distinct()

plot_circumplex(
  df_circumplex,
  "valence_mean",
  "arousal_mean",
  "pieceID",
  "mode"
)


# Points only, no text.
plot_circumplex(
  df_circumplex,
  "valence_mean",
  "arousal_mean",
  "pieceID",
  "mode",
  add_points = TRUE,
  add_text = FALSE
)


# Points with text.
plot_circumplex(
  df_circumplex,
  "valence_mean",
  "arousal_mean",
  "pieceID",
  "mode",
  add_points = TRUE,
  color = "grey", # arg passed to geom_text
  position = ggplot2::position_jitter(width = 0.2)
)