Learn R Programming

colleyRstats (version 0.0.1)

ggbetweenstatsWithPriorNormalityCheck: Check the data's distribution. If non-normal, take the non-parametric variant of ggbetweenstats. x and y have to be in parentheses, e.g., "ConditionID".

Description

Check the data's distribution. If non-normal, take the non-parametric variant of ggbetweenstats. x and y have to be in parentheses, e.g., "ConditionID".

Usage

ggbetweenstatsWithPriorNormalityCheck(
  data,
  x,
  y,
  ylab,
  xlabels,
  showPairwiseComp = TRUE,
  plotType = "boxviolin"
)

Value

A ggplot object produced by ggstatsplot::ggbetweenstats, which can be printed or further modified with +.

Arguments

data

the data frame

x

the independent variable, most likely "ConditionID"

y

the dependent variable under investigation

ylab

label to be shown for the dependent variable

xlabels

labels to be used for the x-axis

showPairwiseComp

whether to show pairwise comparisons, TRUE as default

plotType

either "box", "violin", or "boxviolin" (default)

Examples

Run this code
# \donttest{

set.seed(123)

# Toy within-subject style data
main_df <- data.frame(
  Participant = factor(rep(1:20, each = 3)),
  CondID      = factor(rep(c("A", "B", "C"), times = 20)),
  tlx_mental  = rnorm(60, mean = 50, sd = 10)
)

# Custom x-axis labels
labels_xlab <- c("Condition A", "Condition B", "Condition C")


ggbetweenstatsWithPriorNormalityCheck(
  data = main_df,
  x = "CondID",
  y = "tlx_mental", ylab = "Mental Demand",
  xlabels = labels_xlab,
  showPairwiseComp = TRUE
)
# }

Run the code above in your browser using DataLab