| Title: | Functions to Streamline Statistical Analysis and Reporting |
|---|---|
| Description: | Built upon popular R packages such as 'ggstatsplot' and 'ARTool', this collection offers a wide array of tools for simplifying reproducible analyses, generating high-quality visualizations, and producing 'APA'-compliant outputs. The primary goal of this package is to significantly reduce repetitive coding efforts, allowing you to focus on interpreting results. Whether you're dealing with ANOVA assumptions, reporting effect sizes, or creating publication-ready visualizations, this package makes these tasks easier. |
| Authors: | Mark Colley [aut, cre, cph] (ORCID: <https://orcid.org/0000-0001-5207-5029>) |
| Maintainer: | Mark Colley <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.5 |
| Built: | 2026-06-04 11:12:24 UTC |
| Source: | https://github.com/m-colley/colleyrstats |
PARETO_EMOA Column to a Data FrameThis function calculates the Pareto front using emoa for a given set of objectives in a data frame and adds a new column, PARETO_EMOA, which indicates whether each row in the data frame belongs to the Pareto front.
add_pareto_emoa_column(data, objectives)add_pareto_emoa_column(data, objectives)
data |
A data frame containing the data, including the objective columns. |
objectives |
A character vector specifying the names of the objective columns in |
A data frame with the same columns as data, along with an additional column, PARETO_EMOA, which is TRUE for rows that are on the Pareto front and FALSE otherwise.
# Define objective columns objectives <- c("trust", "predictability", "perceivedSafety", "Comfort") # Example data frame main_df <- data.frame( trust = runif(10), predictability = runif(10), perceivedSafety = runif(10), Comfort = runif(10) ) # Add the Pareto front column main_df <- add_pareto_emoa_column(data = main_df, objectives) head(main_df)# Define objective columns objectives <- c("trust", "predictability", "perceivedSafety", "Comfort") # Example data frame main_df <- data.frame( trust = runif(10), predictability = runif(10), perceivedSafety = runif(10), Comfort = runif(10) ) # Add the Pareto front column main_df <- add_pareto_emoa_column(data = main_df, objectives) head(main_df)
PARETO_MOOCORE Column to a Data FrameThis function calculates the Pareto front using moocore for a given set of objectives in a data frame and adds a new column, PARETO_MOOCORE, which indicates whether each row in the data frame belongs to the Pareto front.
add_pareto_moocore_column(data, objectives)add_pareto_moocore_column(data, objectives)
data |
A data frame containing the data, including the objective columns. |
objectives |
A character vector specifying the names of the objective columns in |
A data frame with the same columns as data, along with an additional column, PARETO_MOOCORE, which is TRUE for rows that are on the Pareto front and FALSE otherwise.
# Define objective columns objectives <- c("trust", "predictability", "perceivedSafety", "Comfort") # Example data frame main_df <- data.frame( trust = runif(10), predictability = runif(10), perceivedSafety = runif(10), Comfort = runif(10) ) # Add the Pareto front column main_df <- add_pareto_moocore_column(data = main_df, objectives) head(main_df)# Define objective columns objectives <- c("trust", "predictability", "perceivedSafety", "Comfort") # Example data frame main_df <- data.frame( trust = runif(10), predictability = runif(10), perceivedSafety = runif(10), Comfort = runif(10) ) # Add the Pareto front column main_df <- add_pareto_moocore_column(data = main_df, objectives) head(main_df)
Check homogeneity of variances across groups
check_homogeneity_by_group(data, x, y)check_homogeneity_by_group(data, x, y)
data |
the data frame |
x |
the grouping variable (column name as string) |
y |
the dependent variable (column name as string) |
TRUE if Levene's test is non-significant (p >= .05), FALSE otherwise
Check normality for groups
check_normality_by_group(data, x, y)check_normality_by_group(data, x, y)
data |
the data frame |
x |
the x column |
y |
the y column |
TRUE if all groups are normal, FALSE otherwise. For groups with more than 5000 non-missing values, Shapiro-Wilk is computed on a random sample of 5000 observations (a warning is emitted); the returned value still reflects that sampled test. Because the sample is drawn randomly, results for such large groups are not reproducible unless a seed is set beforehand.
Check the assumptions for an ANOVA with a variable number of factors: Normality and Homogeneity of variance assumption.
checkAssumptionsForAnova(data, y, factors)checkAssumptionsForAnova(data, y, factors)
data |
the data frame |
y |
The dependent variable for which assumptions should be checked |
factors |
A character vector of factor names |
A message indicating whether to use parametric or non-parametric ANOVA
set.seed(123) main_df <- data.frame( tlx_mental = rnorm(40), Video = factor(rep(c("A", "B"), each = 20)), DriverPosition = factor(rep(c("Left", "Right"), times = 20)) ) checkAssumptionsForAnova( data = main_df, y = "tlx_mental", factors = c("Video", "DriverPosition") )set.seed(123) main_df <- data.frame( tlx_mental = rnorm(40), Video = factor(rep(c("A", "B"), each = 20)), DriverPosition = factor(rep(c("Left", "Right"), times = 20)) ) checkAssumptionsForAnova( data = main_df, y = "tlx_mental", factors = c("Video", "DriverPosition") )
Sets ggplot2 themes and conflict preferences to match the standards used in the colleyRstats workflow.
colleyRstats_setup( set_options = FALSE, set_theme = TRUE, set_conflicts = TRUE, print_citation = TRUE, verbose = TRUE )colleyRstats_setup( set_options = FALSE, set_theme = TRUE, set_conflicts = TRUE, print_citation = TRUE, verbose = TRUE )
set_options |
Logical. If |
set_theme |
Logical. If |
set_conflicts |
Logical. If |
print_citation |
Logical. If |
verbose |
Logical. If |
Invisibly returns NULL.
# Runs everywhere, no extra packages, no session side effects colleyRstats::colleyRstats_setup( set_options = FALSE, set_theme = FALSE, set_conflicts = FALSE, print_citation = FALSE, verbose = FALSE ) # Full setup (requires suggested packages; changes session defaults) if (requireNamespace("ggplot2", quietly = TRUE) && requireNamespace("see", quietly = TRUE)) { local({ old_theme <- ggplot2::theme_get() on.exit(ggplot2::theme_set(old_theme), add = TRUE) colleyRstats::colleyRstats_setup( set_options = FALSE, set_conflicts = FALSE, # avoid persisting conflict prefs in checks print_citation = FALSE, verbose = TRUE ) ggplot2::ggplot(mtcars, ggplot2::aes(mpg, wt)) + ggplot2::geom_point() }) }# Runs everywhere, no extra packages, no session side effects colleyRstats::colleyRstats_setup( set_options = FALSE, set_theme = FALSE, set_conflicts = FALSE, print_citation = FALSE, verbose = FALSE ) # Full setup (requires suggested packages; changes session defaults) if (requireNamespace("ggplot2", quietly = TRUE) && requireNamespace("see", quietly = TRUE)) { local({ old_theme <- ggplot2::theme_get() on.exit(ggplot2::theme_set(old_theme), add = TRUE) colleyRstats::colleyRstats_setup( set_options = FALSE, set_conflicts = FALSE, # avoid persisting conflict prefs in checks print_citation = FALSE, verbose = TRUE ) ggplot2::ggplot(mtcars, ggplot2::aes(mpg, wt)) + ggplot2::geom_point() }) }
Replace all occurrences of given values in all columns of a data frame.
The data data frame contains a collection of records, with attributes organized in columns. It may include various types of values, such as numerical, categorical, or textual data.
replace_values(data, to_replace, replace_with)replace_values(data, to_replace, replace_with)
data |
The input data frame to be modified. |
to_replace |
A vector of values to be replaced within the data frame. This must be the same length as |
replace_with |
A vector of corresponding replacement values. This must be the same length as |
Modified data frame with specified values replaced.
data <- data.frame( q1 = c("neg2", "neg1", "0"), q2 = c("1", "neg2", "neg1") ) replace_values( data, to_replace = c("neg2", "neg1"), replace_with = c("-2", "-1") )data <- data.frame( q1 = c("neg2", "neg1", "0"), q2 = c("1", "neg2", "neg1") ) replace_values( data, to_replace = c("neg2", "neg1"), replace_with = c("-2", "-1") )
Debug contrast errors in ANOVA-like models
debug_contr_error(dat, subset_vec = NULL)debug_contr_error(dat, subset_vec = NULL)
dat |
A data frame of predictors. |
subset_vec |
Optional logical or numeric index vector used to subset rows before checks. |
A list with two elements:
Integer vector giving the number of levels for each factor
variable in dat.
List of factor level labels for each factor variable in
dat.
dat <- data.frame( group = factor(rep(letters[1:3], each = 3)), score = rnorm(9) ) debug_contr_error(dat = dat)dat <- data.frame( group = factor(rep(letters[1:3], each = 3)), score = rnorm(9) ) debug_contr_error(dat = dat)
Function to define a plot, either showing the main or interaction effect in bold.
generateEffectPlot( data, x, y, fillColourGroup, ytext = "testylab", xtext = "testxlab", legendPos = c(0.1, 0.23), legendHeading = NULL, shownEffect = "main", effectLegend = FALSE, effectDescription = NULL, xLabelsOverwrite = NULL, useLatexMarkup = FALSE, numberColors = 6 )generateEffectPlot( data, x, y, fillColourGroup, ytext = "testylab", xtext = "testxlab", legendPos = c(0.1, 0.23), legendHeading = NULL, shownEffect = "main", effectLegend = FALSE, effectDescription = NULL, xLabelsOverwrite = NULL, useLatexMarkup = FALSE, numberColors = 6 )
data |
the data frame |
x |
factor shown on the x-axis |
y |
dependent variable |
fillColourGroup |
group to color |
ytext |
label for y-axis |
xtext |
label for x-axis |
legendPos |
position for legend |
legendHeading |
custom heading for legend |
shownEffect |
either "main" or "interaction" |
effectLegend |
TRUE: show legend for effect (Default: FALSE) |
effectDescription |
custom label for effect |
xLabelsOverwrite |
custom labels for x-axis |
useLatexMarkup |
use latex font and markup |
numberColors |
number of colors |
a plot
set.seed(123) main_df <- data.frame( strategy = factor(rep(c("A", "B"), each = 20)), Emotion = factor(rep(c("Happy", "Sad"), times = 20)), trust_mean = rnorm(40, mean = 5, sd = 1) ) generateEffectPlot( data = main_df, x = "strategy", y = "trust_mean", fillColourGroup = "Emotion", ytext = "Trust", xtext = "Strategy", legendPos = c(0.1, 0.23) )set.seed(123) main_df <- data.frame( strategy = factor(rep(c("A", "B"), each = 20)), Emotion = factor(rep(c("Happy", "Sad"), times = 20)), trust_mean = rnorm(40, mean = 5, sd = 1) ) generateEffectPlot( data = main_df, x = "strategy", y = "trust_mean", fillColourGroup = "Emotion", ytext = "Trust", xtext = "Strategy", legendPos = c(0.1, 0.23) )
This function generates a multi-objective optimization plot using ggplot2. The plot visualizes the relationship between the x and y variables, grouping and coloring by a fill variable, with the option to customize legend position, labels, and annotation of sampling and optimization phases.
generateMoboPlot( data, x, y, fillColourGroup = "ConditionID", ytext, legendPos = c(0.65, 0.85), numberSamplingSteps = 5, labelPosFormulaY = "top", verticalLinePosY = 0.75 )generateMoboPlot( data, x, y, fillColourGroup = "ConditionID", ytext, legendPos = c(0.65, 0.85), numberSamplingSteps = 5, labelPosFormulaY = "top", verticalLinePosY = 0.75 )
data |
A data frame containing the data to be plotted. |
x |
A string representing the column name in |
y |
A string representing the column name in |
fillColourGroup |
A string representing the column name in |
ytext |
A custom label for the y-axis. If not provided, the y-axis label will be the title-cased version of |
legendPos |
A numeric vector of length 2 specifying the position of the legend inside the plot. Default is |
numberSamplingSteps |
An integer specifying the number of initial sampling steps before the optimization phase begins. Default is 5. |
labelPosFormulaY |
A string specifying the vertical position of the polynomial equation label in the plot. Acceptable values are |
verticalLinePosY |
A numeric value of the y-coordinate where the "sampling" and "optimization" line should be drawn. |
A ggplot object representing the multi-objective optimization plot, ready to be rendered.
library(ggplot2) library(ggpmisc) # Example with numeric x-axis df <- data.frame( x = 1:20, y = rnorm(20), ConditionID = rep(c("A", "B"), 10) ) generateMoboPlot(df, x = "x", y = "y") # Example with factor x-axis df <- data.frame( x = factor(rep(1:5, each = 4)), y = rnorm(20), ConditionID = rep(c("A", "B"), 10) ) generateMoboPlot(df, x = "x", y = "y", numberSamplingSteps = 3)library(ggplot2) library(ggpmisc) # Example with numeric x-axis df <- data.frame( x = 1:20, y = rnorm(20), ConditionID = rep(c("A", "B"), 10) ) generateMoboPlot(df, x = "x", y = "y") # Example with factor x-axis df <- data.frame( x = factor(rep(1:5, each = 4)), y = rnorm(20), ConditionID = rep(c("A", "B"), 10) ) generateMoboPlot(df, x = "x", y = "y", numberSamplingSteps = 3)
This function generates a multi-objective optimization plot using ggplot2. The plot visualizes the relationship between the x and y variables, grouping and coloring by a fill variable, with the option to customize legend position, labels, and annotation of sampling and optimization phases.
Appropriate if you use https://github.com/Pascal-Jansen/Bayesian-Optimization-for-Unity in version 1.1.0 or higher.
generateMoboPlot2( data, x = "Iteration", y, phaseCol = "Phase", fillColourGroup = "ConditionID", ytext, legendPos = c(0.65, 0.85), labelPosFormulaY = "top", labelPosFormulaX = "left", horizontalLinePosY = 0.75, horizontalLineDistToText = 0.3, fillLabels = NULL, annotationTextSize = 5 )generateMoboPlot2( data, x = "Iteration", y, phaseCol = "Phase", fillColourGroup = "ConditionID", ytext, legendPos = c(0.65, 0.85), labelPosFormulaY = "top", labelPosFormulaX = "left", horizontalLinePosY = 0.75, horizontalLineDistToText = 0.3, fillLabels = NULL, annotationTextSize = 5 )
data |
A data frame containing the data to be plotted. |
x |
A string representing the column name in |
y |
A string representing the column name in |
phaseCol |
the name of the column for the color of the phase (sampling or optimization) |
fillColourGroup |
A string representing the column name in |
ytext |
A custom label for the y-axis. If not provided, the y-axis label will be the title-cased version of |
legendPos |
A numeric vector of length 2 specifying the position of the legend inside the plot. Default is |
labelPosFormulaY |
A string specifying the vertical position of the polynomial equation label in the plot. Acceptable values are |
labelPosFormulaX |
A string specifying the position of the polynomial equation label in the plot. Acceptable values are |
horizontalLinePosY |
A numeric value of the y-coordinate where the "sampling" and "optimization" line should be drawn. Default is |
horizontalLineDistToText |
A numeric value of the y-coordinate where the "sampling" and "optimization" text should be drawn below the line. Default is |
fillLabels |
An optional named character vector mapping raw factor levels to display labels for the fill/colour legend (e.g. |
annotationTextSize |
numeric. The font size for embedded text annotations inside the plot (e.g., "Sampling", "Optimization" labels, and the regression equations). Default is |
A ggplot object representing the multi-objective optimization plot, ready to be rendered.
library(ggplot2) library(ggpmisc) # Example with numeric x-axis df <- data.frame( x = 1:20, y = rnorm(20), ConditionID = rep(c("A", "B"), 10), Phase = rep(c("Sampling", "Optimization"), 10) ) generateMoboPlot2(data = df, x = "x", y = "y")library(ggplot2) library(ggpmisc) # Example with numeric x-axis df <- data.frame( x = 1:20, y = rnorm(20), ConditionID = rep(c("A", "B"), 10), Phase = rep(c("Sampling", "Optimization"), 10) ) generateMoboPlot2(data = df, x = "x", y = "y")
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".
ggbetweenstatsWithPriorNormalityCheck( data, x, y, ylab, xlabels = NULL, showPairwiseComp = TRUE, plotType = "boxviolin" )ggbetweenstatsWithPriorNormalityCheck( data, x, y, ylab, xlabels = NULL, showPairwiseComp = TRUE, plotType = "boxviolin" )
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) |
A ggplot object produced by ggstatsplot::ggbetweenstats, which can be printed or further modified with +.
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 )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 )
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".
ggbetweenstatsWithPriorNormalityCheckAsterisk( data, x, y, ylab, xlabels, plotType = "boxviolin" )ggbetweenstatsWithPriorNormalityCheckAsterisk( data, x, y, ylab, xlabels, plotType = "boxviolin" )
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 |
plotType |
either "box", "violin", or "boxviolin" (default) |
A ggplot object produced by ggstatsplot::ggbetweenstats
with additional significance annotations, which can be printed or modified.
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") ggbetweenstatsWithPriorNormalityCheckAsterisk( data = main_df, x = "CondID", y = "tlx_mental", ylab = "Mental Demand", xlabels = labels_xlab )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") ggbetweenstatsWithPriorNormalityCheckAsterisk( data = main_df, x = "CondID", y = "tlx_mental", ylab = "Mental Demand", xlabels = labels_xlab )
Check the data's distribution. If non-normal, take the non-parametric variant of ggwithinstats. x and y have to be in parentheses, e.g., "ConditionID".
ggwithinstatsWithPriorNormalityCheck( data, x, y, ylab, xlabels = NULL, showPairwiseComp = TRUE, plotType = "boxviolin" )ggwithinstatsWithPriorNormalityCheck( data, x, y, ylab, xlabels = NULL, showPairwiseComp = TRUE, plotType = "boxviolin" )
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) |
A ggplot object produced by ggstatsplot::ggwithinstats with additional significance annotations, which can be printed or modified.
#' 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") ggwithinstatsWithPriorNormalityCheck( data = main_df, x = "CondID", y = "tlx_mental", ylab = "Mental Demand", xlabels = labels_xlab, showPairwiseComp = TRUE )#' 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") ggwithinstatsWithPriorNormalityCheck( data = main_df, x = "CondID", y = "tlx_mental", ylab = "Mental Demand", xlabels = labels_xlab, showPairwiseComp = TRUE )
Check the data's distribution. If non-normal, take the non-parametric variant of ggwithinstats. x and y have to be in parentheses, e.g., "ConditionID". Add Asterisks instead of p-values.
ggwithinstatsWithPriorNormalityCheckAsterisk( data, x, y, ylab, xlabels, plotType = "boxviolin" )ggwithinstatsWithPriorNormalityCheckAsterisk( data, x, y, ylab, xlabels, plotType = "boxviolin" )
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 |
plotType |
either "box", "violin", or "boxviolin" (default) |
A ggplot object produced by ggstatsplot::ggwithinstats
with additional significance annotations, which can be printed or modified.
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") ggwithinstatsWithPriorNormalityCheckAsterisk( data = main_df, x = "CondID", y = "tlx_mental", ylab = "Mental Demand", xlabels = labels_xlab )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") ggwithinstatsWithPriorNormalityCheckAsterisk( data = main_df, x = "CondID", y = "tlx_mental", ylab = "Mental Demand", xlabels = labels_xlab )
report::report() into LaTeX-friendly output.This function transforms the text output from report::report() by performing several substitutions
to prepare the text for LaTeX typesetting. In particular, it replaces instances of R2, %, and ~ with
the corresponding LaTeX code. Additionally, it provides options to:
Omit bullet items marked as "non-significant" (when only_sig = TRUE).
Remove a concluding note about standardized parameters (when remove_std = TRUE).
Wrap bullet items in a LaTeX itemize environment or leave them as plain text (controlled by itemize).
latexify_report( x, print_result = TRUE, only_sig = FALSE, remove_std = FALSE, itemize = TRUE )latexify_report( x, print_result = TRUE, only_sig = FALSE, remove_std = FALSE, itemize = TRUE )
x |
Character vector or a single string containing the report text. |
print_result |
Logical. If |
only_sig |
Logical. If |
remove_std |
Logical. If |
itemize |
Logical. If |
A single string with the LaTeX-friendly formatted report text.
if (requireNamespace("report", quietly = TRUE)) { # Simple linear model on the iris dataset model <- stats::lm( Sepal.Length ~ Sepal.Width + Petal.Length, data = datasets::iris ) # Format the report output, showing only significant items, removing the # standard note, and wrapping bullet items in an itemize environment. report_text <- try(report::report(model), silent = TRUE) if (!inherits(report_text, "try-error")) { latexify_report( report_text, only_sig = TRUE, remove_std = TRUE, itemize = TRUE ) } }if (requireNamespace("report", quietly = TRUE)) { # Simple linear model on the iris dataset model <- stats::lm( Sepal.Length ~ Sepal.Width + Petal.Length, data = datasets::iris ) # Format the report output, showing only significant items, removing the # standard note, and wrapping bullet items in an itemize environment. report_text <- try(report::report(model), silent = TRUE) if (!inherits(report_text, "try-error")) { latexify_report( report_text, only_sig = TRUE, remove_std = TRUE, itemize = TRUE ) } }
Build a median/size label for plot annotations
n_fun(x)n_fun(x)
x |
A numeric vector. |
A data frame with the median and label.
Replace NA values with zero
na.zero(x)na.zero(x)
x |
A vector. |
A vector with NAs replaced by zeros.
na.zero(c(NA, 1, NA, 2))na.zero(c(NA, 1, NA, 2))
This function normalizes the values in a vector to the range [new_min, new_max] based on their original range [old_min, old_max].
normalize(x_vector, old_min, old_max, new_min, new_max)normalize(x_vector, old_min, old_max, new_min, new_max)
x_vector |
A numeric vector that you want to normalize. |
old_min |
The minimum value in the original scale of the data. |
old_max |
The maximum value in the original scale of the data. |
new_min |
The minimum value in the new scale to which you want to normalize the data. |
new_max |
The maximum value in the new scale to which you want to normalize the data. |
A numeric vector with the normalized values.
normalize(c(1, 2, 3, 4, 5), 1, 5, 0, 1)normalize(c(1, 2, 3, 4, 5), 1, 5, 0, 1)
Stops execution if x is NULL, empty, or contains only NAs.
not_empty(x, msg = "Input must not be empty.")not_empty(x, msg = "Input must not be empty.")
x |
The object to check |
msg |
The error message to display |
Invisible TRUE if valid.
%in% membershipNegate %in% membership
not_in(x, y) x %!in% ynot_in(x, y) x %!in% y
x |
Vector of values to test. |
y |
Vector of values to match against. |
Logical vector indicating non-membership.
Convert Windows paths to R-friendly format
pathPrep(path = "clipboard", read_fn = NULL, write_fn = NULL)pathPrep(path = "clipboard", read_fn = NULL, write_fn = NULL)
path |
Path to convert or the string "clipboard" to read from the clipboard. |
read_fn |
Optional custom function to read from the clipboard. |
write_fn |
Optional custom function to write to the clipboard. |
A normalized path string.
This function takes a data frame, optional header information, variables to consider, and a range for a Likert scale. It then calculates the Response Entropy Index (REI) and flags suspicious entries based on percentiles.
remove_outliers_REI(df, header = FALSE, variables = "", range = c(1, 5))remove_outliers_REI(df, header = FALSE, variables = "", range = c(1, 5))
df |
Data frame containing the data. |
header |
Logical indicating if the data frame has a header. Defaults to FALSE. |
variables |
Character string specifying which variables to consider, separated by commas. |
range |
Numeric vector specifying the range of the Likert scale. Defaults to c(1, 5). |
For more information on the REI method, refer to: Response Entropy Index Method
A data frame with calculated REI, percentile, and a 'Suspicious' flag.
df <- data.frame(var1 = c(1, 2, 3), var2 = c(2, 3, 4)) result <- remove_outliers_REI(df, TRUE, "var1,var2", c(1, 5))df <- data.frame(var1 = c(1, 2, 3), var2 = c(2, 3, 4)) result <- remove_outliers_REI(df, TRUE, "var1,var2", c(1, 5))
To easily copy and paste the results to your manuscript, the following commands must be defined in Latex:
\newcommand{\F}[3]{$F({#1},{#2})={#3}$}
\newcommand{\p}{\textit{p=}}
\newcommand{\pminor}{\textit{p$<$}}
reportART(model, dv = "Testdependentvariable", write_to_clipboard = FALSE)reportART(model, dv = "Testdependentvariable", write_to_clipboard = FALSE)
model |
the model of the art |
dv |
the name of the dependent variable that should be reported |
write_to_clipboard |
whether to write to the clipboard |
A message describing the statistical results.
if (requireNamespace("ARTool", quietly = TRUE)) { set.seed(123) main_df <- data.frame( tlx_mental = stats::rnorm(80), Video = factor(rep(c("A", "B"), each = 40)), gesture = factor(rep(c("G1", "G2"), times = 40)), eHMI = factor(rep(c("On", "Off"), times = 40)), UserID = factor(rep(1:20, each = 4)) ) art_model <- ARTool::art( tlx_mental ~ Video * gesture * eHMI + Error(UserID / (gesture * eHMI)), data = main_df ) model_anova <- stats::anova(art_model) reportART(model_anova, dv = "mental demand") }if (requireNamespace("ARTool", quietly = TRUE)) { set.seed(123) main_df <- data.frame( tlx_mental = stats::rnorm(80), Video = factor(rep(c("A", "B"), each = 40)), gesture = factor(rep(c("G1", "G2"), times = 40)), eHMI = factor(rep(c("On", "Off"), times = 40)), UserID = factor(rep(1:20, each = 4)) ) art_model <- ARTool::art( tlx_mental ~ Video * gesture * eHMI + Error(UserID / (gesture * eHMI)), data = main_df ) model_anova <- stats::anova(art_model) reportART(model_anova, dv = "mental demand") }
Companion to reportDunnTest() for aligned-rank-transform (ART) models. It
extracts the significant pairwise comparisons produced by ARTool::art.con()
(an emmeans contrast grid), computes the mean and standard deviation of
the groups involved from the raw data, and prints LaTeX-formatted sentences.
reportArtCon(ac, data, iv = "testiv", dv = "testdv", paired = FALSE, id = NULL)reportArtCon(ac, data, iv = "testiv", dv = "testdv", paired = FALSE, id = NULL)
ac |
the contrast object returned by |
data |
the raw data frame used to fit the model |
iv |
independent variable (the contrasted factor) |
dv |
dependent variable |
paired |
whether to compute the rank-biserial effect size for paired
(within-subjects) data. Defaults to |
id |
the subject/pairing column, used only when |
The p-values are taken as-is from the contrast object, i.e. they are already
adjusted by whatever adjust was passed to art.con() (e.g. "holm"). The
effect size is the rank-biserial correlation computed from the raw data. ART
is most often used for within-subjects designs; pass paired = TRUE together
with id (the subject column) to obtain the paired rank-biserial effect size.
Attention: ac must be a pairwise contrast over a single factor iv
(e.g. art.con(model, ~ interaction_mode, adjust = "holm")).
Required commands in LaTeX:
\newcommand{\padjminor}{\textit{p$_{adj}<$}}
\newcommand{\padj}{\textit{p$_{adj}$=}}
\newcommand{\rankbiserial}[1]{$r_{rb} = #1$}
A message describing the statistical results.
if (requireNamespace("ARTool", quietly = TRUE) && requireNamespace("emmeans", quietly = TRUE)) { set.seed(123) n <- 20 df <- data.frame( UserID = factor(rep(seq_len(n), times = 3)), mode = factor(rep(c("Hand", "Eye", "Both"), each = n)), prime = factor(rep(rep(c("A", "B"), each = n / 2), times = 3)) ) df$score <- as.numeric(df$mode) * 2 + stats::rnorm(nrow(df)) m <- ARTool::art(score ~ mode * prime + Error(UserID / mode), data = df) ac <- ARTool::art.con(m, ~ mode, adjust = "holm") reportArtCon(ac, data = df, iv = "mode", dv = "score", paired = TRUE, id = "UserID") }if (requireNamespace("ARTool", quietly = TRUE) && requireNamespace("emmeans", quietly = TRUE)) { set.seed(123) n <- 20 df <- data.frame( UserID = factor(rep(seq_len(n), times = 3)), mode = factor(rep(c("Hand", "Eye", "Both"), each = n)), prime = factor(rep(rep(c("A", "B"), each = n / 2), times = 3)) ) df$score <- as.numeric(df$mode) * 2 + stats::rnorm(nrow(df)) m <- ARTool::art(score ~ mode * prime + Error(UserID / mode), data = df) ac <- ARTool::art.con(m, ~ mode, adjust = "holm") reportArtCon(ac, data = df, iv = "mode", dv = "score", paired = TRUE, id = "UserID") }
reportDunnTestTable().Required commands in LaTeX:
\newcommand{\padjminor}{\textit{p$_{adj}<$}}
\newcommand{\padj}{\textit{p$_{adj}$=}}
\newcommand{\rankbiserial}[1]{$r_{rb} = #1$}
reportArtConTable( ac, data, iv = "testiv", dv = "testdv", paired = FALSE, id = NULL, orderByP = FALSE, numberDigitsForPValue = 4, latexSize = "small", orderText = TRUE )reportArtConTable( ac, data, iv = "testiv", dv = "testdv", paired = FALSE, id = NULL, orderByP = FALSE, numberDigitsForPValue = 4, latexSize = "small", orderText = TRUE )
ac |
the contrast object returned by |
data |
the raw data frame used to fit the model |
iv |
independent variable (the contrasted factor) |
dv |
dependent variable |
paired |
whether to compute the rank-biserial effect size for paired
(within-subjects) data. Defaults to |
id |
the subject/pairing column, used only when |
orderByP |
whether to order by the p value |
numberDigitsForPValue |
the number of digits to show |
latexSize |
which size for the text |
orderText |
whether to order the text |
A message describing the statistical results in a table.
if (requireNamespace("ARTool", quietly = TRUE) && requireNamespace("emmeans", quietly = TRUE)) { set.seed(123) n <- 20 df <- data.frame( UserID = factor(rep(seq_len(n), times = 3)), mode = factor(rep(c("Hand", "Eye", "Both"), each = n)), prime = factor(rep(rep(c("A", "B"), each = n / 2), times = 3)) ) df$score <- as.numeric(df$mode) * 2 + stats::rnorm(nrow(df)) m <- ARTool::art(score ~ mode * prime + Error(UserID / mode), data = df) ac <- ARTool::art.con(m, ~ mode, adjust = "holm") reportArtConTable(ac, data = df, iv = "mode", dv = "score", paired = TRUE, id = "UserID") }if (requireNamespace("ARTool", quietly = TRUE) && requireNamespace("emmeans", quietly = TRUE)) { set.seed(123) n <- 20 df <- data.frame( UserID = factor(rep(seq_len(n), times = 3)), mode = factor(rep(c("Hand", "Eye", "Both"), each = n)), prime = factor(rep(rep(c("A", "B"), each = n / 2), times = 3)) ) df$score <- as.numeric(df$mode) * 2 + stats::rnorm(nrow(df)) m <- ARTool::art(score ~ mode * prime + Error(UserID / mode), data = df) ac <- ARTool::art.con(m, ~ mode, adjust = "holm") reportArtConTable(ac, data = df, iv = "mode", dv = "score", paired = TRUE, id = "UserID") }
\newcommand{\padjminor}{\textit{p$_{adj}<$}}
\newcommand{\padj}{\textit{p$_{adj}$=}}
\newcommand{\rankbiserial}[1]{$r_{rb} = #1$}
Report dunnTest as text. Required commands in LaTeX:
\newcommand{\padjminor}{\textit{p$_{adj}<$}}
\newcommand{\padj}{\textit{p$_{adj}$=}}
\newcommand{\rankbiserial}[1]{$r_{rb} = #1$}
reportDunnTest(d, data, iv = "testiv", dv = "testdv")reportDunnTest(d, data, iv = "testiv", dv = "testdv")
d |
the dunn test object |
data |
the data frame |
iv |
independent variable |
dv |
dependent variable |
A message describing the statistical results.
if (requireNamespace("FSA", quietly = TRUE)) { # Use built-in iris data data(iris) # Dunn test on Sepal.Length by Species d <- FSA::dunnTest(Sepal.Length ~ Species, data = iris, method = "holm" ) # Report the Dunn test reportDunnTest(d, data = iris, iv = "Species", dv = "Sepal.Length" ) }if (requireNamespace("FSA", quietly = TRUE)) { # Use built-in iris data data(iris) # Dunn test on Sepal.Length by Species d <- FSA::dunnTest(Sepal.Length ~ Species, data = iris, method = "holm" ) # Report the Dunn test reportDunnTest(d, data = iris, iv = "Species", dv = "Sepal.Length" ) }
\newcommand{\padjminor}{\textit{p$_{adj}<$}}
\newcommand{\padj}{\textit{p$_{adj}$=}}
\newcommand{\rankbiserial}[1]{$r_{rb} = #1$}
report Dunn test as a table. Customizable with sensible defaults. Required commands in LaTeX:
\newcommand{\padjminor}{\textit{p$_{adj}<$}}
\newcommand{\padj}{\textit{p$_{adj}$=}}
\newcommand{\rankbiserial}[1]{$r_{rb} = #1$}
reportDunnTestTable( d = NULL, data, iv = "testiv", dv = "testdv", orderByP = FALSE, numberDigitsForPValue = 4, latexSize = "small", orderText = TRUE )reportDunnTestTable( d = NULL, data, iv = "testiv", dv = "testdv", orderByP = FALSE, numberDigitsForPValue = 4, latexSize = "small", orderText = TRUE )
d |
the dunn test object |
data |
the data frame |
iv |
independent variable |
dv |
dependent variable |
orderByP |
whether to order by the p value |
numberDigitsForPValue |
the number of digits to show |
latexSize |
which size for the text |
orderText |
whether to order the text |
A message describing the statistical results in a table.
if (requireNamespace("FSA", quietly = TRUE)) { # Use built-in iris data data(iris) # Dunn test on Sepal.Length by Species d <- FSA::dunnTest(Sepal.Length ~ Species, data = iris, method = "holm" ) # Report the Dunn test reportDunnTestTable(d, data = iris, iv = "Species", dv = "Sepal.Length" ) }if (requireNamespace("FSA", quietly = TRUE)) { # Use built-in iris data data(iris) # Dunn test on Sepal.Length by Species d <- FSA::dunnTest(Sepal.Length ~ Species, data = iris, method = "holm" ) # Report the Dunn test reportDunnTestTable(d, data = iris, iv = "Species", dv = "Sepal.Length" ) }
Report statistical details for ggstatsplot.
reportggstatsplot( p, iv = "independent", dv = "Testdependentvariable", write_to_clipboard = FALSE )reportggstatsplot( p, iv = "independent", dv = "Testdependentvariable", write_to_clipboard = FALSE )
p |
the object returned by ggwithinstats or ggbetweenstats |
iv |
the independent variable |
dv |
the dependent variable |
write_to_clipboard |
whether to write to the clipboard |
A message describing the statistical results.
library(ggstatsplot) library(dplyr) # Generate a plot plt <- ggbetweenstats(mtcars, am, mpg) reportggstatsplot(plt, iv = "am", dv = "mpg")library(ggstatsplot) library(dplyr) # Generate a plot plt <- ggbetweenstats(mtcars, am, mpg) reportggstatsplot(plt, iv = "am", dv = "mpg")
This function extracts significant pairwise comparisons from a ggstatsplot object,
calculates the mean and standard deviation for the groups involved using the raw data,
and prints LaTeX-formatted sentences reporting the results.
reportggstatsplotPostHoc( data, p, iv = "testiv", dv = "testdv", label_mappings = NULL )reportggstatsplotPostHoc( data, p, iv = "testiv", dv = "testdv", label_mappings = NULL )
data |
A data frame containing the raw data used to generate the plot. |
p |
A |
iv |
Character string. The column name of the independent variable (grouping variable). |
dv |
Character string. The column name of the dependent variable. |
label_mappings |
Optional named list or vector. Used to rename factor levels in the output text
(e.g., |
No return value. The function prints LaTeX-formatted text to the console.
To easily copy and paste the results to your manuscript, the following commands
(or similar) must be defined in your LaTeX preamble, as the function outputs
commands taking arguments (e.g., \m{value}):
\newcommand{\m}[1]{\textit{M}=#1}
\newcommand{\sd}[1]{\textit{SD}=#1}
\newcommand{\padj}[1]{$p_{adj}=#1$}
\newcommand{\padjminor}[1]{$p_{adj}<#1$}
library(ggstatsplot) library(dplyr) # Generate a plot plt <- ggbetweenstats(mtcars, am, mpg) # Report stats reportggstatsplotPostHoc( data = mtcars, p = plt, iv = "am", dv = "mpg", label_mappings = list("0" = "Automatic", "1" = "Manual") )library(ggstatsplot) library(dplyr) # Generate a plot plt <- ggbetweenstats(mtcars, am, mpg) # Report stats reportggstatsplotPostHoc( data = mtcars, p = plt, iv = "am", dv = "mpg", label_mappings = list("0" = "Automatic", "1" = "Manual") )
#' To easily copy and paste the results to your manuscript, the following commands must be defined in Latex:
\newcommand{\m}{\textit{M=}}
\newcommand{\sd}{\textit{SD=}}
reportMeanAndSD(data, iv = "testiv", dv = "testdv")reportMeanAndSD(data, iv = "testiv", dv = "testdv")
data |
the data frame |
iv |
the independent variable |
dv |
the dependent variable |
Mean and SD values
example_data <- data.frame(Condition = rep(c("A", "B", "C"), each = 10), TLX1 = stats::rnorm(30)) reportMeanAndSD(example_data, iv = "Condition", dv = "TLX1")example_data <- data.frame(Condition = rep(c("A", "B", "C"), each = 10), TLX1 = stats::rnorm(30)) reportMeanAndSD(example_data, iv = "Condition", dv = "TLX1")
nparLD (see https://CRAN.R-project.org/package=nparLD).#' Only significant main and interaction effects are reported. P-values are rounded for the third digit and relative treatment effects (RTE) are included when available. Attention: the independent variables of the formula and the term specifying the participant must be factors (i.e., use as.factor()).
reportNparLD(model, dv = "Testdependentvariable", write_to_clipboard = FALSE)reportNparLD(model, dv = "Testdependentvariable", write_to_clipboard = FALSE)
model |
the model |
dv |
the dependent variable |
write_to_clipboard |
whether to write to the clipboard |
#' To easily copy and paste the results to your manuscript, the following commands must be defined in Latex:
\newcommand{\F}{\textit{F=}}
\newcommand{\p}{\textit{p=}}
\newcommand{\pminor}{\textit{p$<$}}
A message describing the statistical results.
if (requireNamespace("nparLD", quietly = TRUE)) { # Small toy data set for nparLD set.seed(123) example_data <- data.frame( Subject = factor(rep(1:10, each = 3)), Time = factor(rep(c("T1", "T2", "T3"), times = 10)), TLX1 = stats::rnorm(30, mean = 50, sd = 10) ) # Fit nparLD model model <- nparLD::nparLD( TLX1 ~ Time, data = example_data, subject = "Subject", description = FALSE ) # Report the nparLD result reportNparLD(model, dv = "TLX1") }if (requireNamespace("nparLD", quietly = TRUE)) { # Small toy data set for nparLD set.seed(123) example_data <- data.frame( Subject = factor(rep(1:10, each = 3)), Time = factor(rep(c("T1", "T2", "T3"), times = 10)), TLX1 = stats::rnorm(30, mean = 50, sd = 10) ) # Fit nparLD model model <- nparLD::nparLD( TLX1 ~ Time, data = example_data, subject = "Subject", description = FALSE ) # Report the nparLD result reportNparLD(model, dv = "TLX1") }
Deprecated: reportNPAV() will be removed in colleyRstats 0.1.0.
Use reportART() with ARTool instead.
reportNPAV(model, dv = "Testdependentvariable", write_to_clipboard = FALSE)reportNPAV(model, dv = "Testdependentvariable", write_to_clipboard = FALSE)
model |
the model of the np.anova |
dv |
the name of the dependent variable that should be reported |
write_to_clipboard |
whether to write to the clipboard |
To easily copy and paste the results to your manuscript, the following commands must be defined in Latex:
\newcommand{\F}[3]{$F({#1},{#2})={#3}$}
\newcommand{\p}{\textit{p=}}
\newcommand{\pminor}{\textit{p$<$}}
A message describing the statistical results.
model <- data.frame( Df = c(1, 1, 10), `F value` = c(6.12, 5.01, NA), `Pr(>F)` = c(0.033, 0.045, NA), check.names = FALSE ) rownames(model) <- c("Video", "gesture:eHMI", "Residuals") reportNPAV(model, dv = "mental workload")model <- data.frame( Df = c(1, 1, 10), `F value` = c(6.12, 5.01, NA), `Pr(>F)` = c(0.033, 0.045, NA), check.names = FALSE ) rownames(model) <- c("Video", "gesture:eHMI", "Residuals") reportNPAV(model, dv = "mental workload")
This function takes an Excel file with data in a wide format and transforms it to a long format. It includes a customizable "ID" column in the first position and repeats it for each slice. The function identifies sections of columns between markers that start with a user-defined string (default is "videoinfo") and appends those sections under the first section, aligning by column index.
reshape_data( input_filepath, sheetName = "Results", marker = "videoinfo", id_col = "ID", output_filepath )reshape_data( input_filepath, sheetName = "Results", marker = "videoinfo", id_col = "ID", output_filepath )
input_filepath |
String, the file path of the input Excel file. |
sheetName |
String, the name of the sheet to read from the Excel file. Default is "Results". |
marker |
String, the string that identifies the start of a new section of columns. Default is "videoinfo". |
id_col |
String, the name of the column to use as the ID column. Default is "ID". |
output_filepath |
String, the file path for the output Excel file. |
Relevant if you receive data in wide-format but cannot use built-in functionality due to naming (e.g., in LimeSurvey)
None, writes the reshaped data to an Excel file specified by output_filepath.
if (requireNamespace(c("write_xlsx", "readxl"), quietly = TRUE)) { tmp_in <- tempfile(fileext = ".xlsx") tmp_out <- tempfile(fileext = ".xlsx") # Minimal toy input that includes your required pieces: # an ID column and something that contains the marker value. toy <- data.frame( ID = c(1, 1, 2, 2), section = c("videoinfo", "videoinfo", "videoinfo", "videoinfo"), key = c("fps", "duration_s", "fps", "duration_s"), value = c(30, 12.3, 25, 9.8), stringsAsFactors = FALSE ) writexl::write_xlsx(toy, tmp_in) reshape_data( input_filepath = tmp_in, marker = "videoinfo", id_col = "ID", output_filepath = tmp_out ) out <- readxl::read_excel(tmp_out) print(out) }if (requireNamespace(c("write_xlsx", "readxl"), quietly = TRUE)) { tmp_in <- tempfile(fileext = ".xlsx") tmp_out <- tempfile(fileext = ".xlsx") # Minimal toy input that includes your required pieces: # an ID column and something that contains the marker value. toy <- data.frame( ID = c(1, 1, 2, 2), section = c("videoinfo", "videoinfo", "videoinfo", "videoinfo"), key = c("fps", "duration_s", "fps", "duration_s"), value = c(30, 12.3, 25, 9.8), stringsAsFactors = FALSE ) writexl::write_xlsx(toy, tmp_in) reshape_data( input_filepath = tmp_in, marker = "videoinfo", id_col = "ID", output_filepath = tmp_out ) out <- readxl::read_excel(tmp_out) print(out) }
Calculation based on Rosenthal's formula (1994). N stands for the number of measurements. Necessary command:
rFromNPAV(pvalue, N)rFromNPAV(pvalue, N)
pvalue |
p value |
N |
number of measurements in the experiment |
Invisibly returns a list with components:
r: effect size as a numeric scalar.
z: corresponding z-statistic.
text: LaTeX-formatted character string that is also sent
to the console.
rFromNPAV(0.02, N = 180)rFromNPAV(0.02, N = 180)
Calculation based on Rosenthal's formula (1994). N stands for the number of measurements.
rFromWilcox(wilcoxModel, N)rFromWilcox(wilcoxModel, N)
wilcoxModel |
the Wilcox model |
N |
number of measurements in the experiment |
Invisibly returns a list with components:
r: effect size as a numeric scalar.
z: corresponding z-statistic.
text: character string that is also sent to the console.
set.seed(1) d <- data.frame( group = rep(c("A", "B"), each = 10), value = rnorm(20) ) w <- stats::wilcox.test(value ~ group, data = d, exact = FALSE) rFromWilcox(w, N = nrow(d))set.seed(1) d <- data.frame( group = rep(c("A", "B"), each = 10), value = rnorm(20) ) w <- stats::wilcox.test(value ~ group, data = d, exact = FALSE) rFromWilcox(w, N = nrow(d))
rFromWilcoxAdjusted
rFromWilcoxAdjusted(wilcoxModel, N, adjustFactor)rFromWilcoxAdjusted(wilcoxModel, N, adjustFactor)
wilcoxModel |
the Wilcox model |
N |
number of measurements in the experiment |
adjustFactor |
ad adjustment factor |
Invisibly returns a list with components:
r: adjusted effect size as a numeric scalar.
z: adjusted z-statistic.
text: character string that is also sent to the console.
set.seed(1) d <- data.frame( group = rep(c("A", "B"), each = 10), value = rnorm(20) ) w <- stats::wilcox.test(value ~ group, data = d, exact = FALSE) rFromWilcoxAdjusted(w, N = nrow(d), adjustFactor = 2)set.seed(1) d <- data.frame( group = rep(c("A", "B"), each = 10), value = rnorm(20) ) w <- stats::wilcox.test(value ~ group, data = d, exact = FALSE) rFromWilcoxAdjusted(w, N = nrow(d), adjustFactor = 2)
Generating the sum and adding a crossbar.
stat_sum_df(fun, geom = "crossbar", ...)stat_sum_df(fun, geom = "crossbar", ...)
fun |
function |
geom |
geom to be shown |
... |
Additional arguments passed to stat_summary |
A ggplot2 layer that can be added to a ggplot object.
# Simple summary function: use the mean as y, ymin, and ymax mean_fun <- function(x) { m <- mean(x, na.rm = TRUE) data.frame(y = m, ymin = m, ymax = m) } ggplot2::ggplot(mtcars, ggplot2::aes(x = factor(cyl), y = mpg)) + stat_sum_df(mean_fun)# Simple summary function: use the mean as y, ymin, and ymax mean_fun <- function(x) { m <- mean(x, na.rm = TRUE) data.frame(y = m, ymin = m, ymax = m) } ggplot2::ggplot(mtcars, ggplot2::aes(x = factor(cyl), y = mpg)) + stat_sum_df(mean_fun)