compare_groups {kim} | R Documentation |
Compare groups
Description
Compares groups by (1) creating histogram by group; (2) summarizing descriptive statistics by group; and (3) conducting pairwise comparisons (t-tests and Mann-Whitney tests).
Usage
compare_groups(
data = NULL,
iv_name = NULL,
dv_name = NULL,
sigfigs = 3,
stats = "basic",
cohen_d = TRUE,
cohen_d_w_ci = TRUE,
adjust_p = "holm",
bonferroni = NULL,
mann_whitney = TRUE,
t_test_stats = TRUE,
t_test_df_decimals = 1,
round_p = 3,
save_as_png = FALSE,
png_name = NULL,
xlab = NULL,
ylab = NULL,
x_limits = NULL,
x_breaks = NULL,
x_labels = NULL,
width = 5000,
height = 3600,
units = "px",
res = 300,
layout_matrix = NULL,
col_names_nicer = TRUE,
convert_dv_to_numeric = TRUE
)
Arguments
data |
a data object (a data frame or a data.table) |
iv_name |
name of the independent variable (grouping variable) |
dv_name |
name of the dependent variable (measure variable of interest) |
sigfigs |
number of significant digits to round to |
stats |
statistics to calculate for each group.
If |
cohen_d |
if |
cohen_d_w_ci |
if |
adjust_p |
the name of the method to use to adjust p-values.
If |
bonferroni |
The use of this argument is deprecated.
Use the 'adjust_p' argument instead.
If |
mann_whitney |
if |
t_test_stats |
if |
t_test_df_decimals |
number of decimals for the degrees of freedom in t-tests (default = 1) |
round_p |
number of decimal places to which to round p-values (default = 3) |
save_as_png |
if |
png_name |
name of the PNG file to be saved. By default, the name will be "compare_groups_results_" followed by a timestamp of the current time. The timestamp will be in the format, jan_01_2021_1300_10_000001, where "jan_01_2021" would indicate January 01, 2021; 1300 would indicate 13:00 (i.e., 1 PM); and 10_000001 would indicate 10.000001 seconds after the hour. |
xlab |
title of the x-axis for the histogram by group.
If |
ylab |
title of the y-axis for the histogram by group.
If |
x_limits |
a numeric vector with values of the endpoints of the x axis. |
x_breaks |
a numeric vector indicating the points at which to place tick marks on the x axis. |
x_labels |
a vector containing labels for the place tick marks on the x axis. |
width |
width of the PNG file (default = 4000) |
height |
height of the PNG file (default = 3000) |
units |
the units for the |
res |
The nominal resolution in ppi which will be recorded in the png file, if a positive integer. Used for units other than the default. If not specified, taken as 300 ppi to set the size of text and line widths. |
layout_matrix |
The layout argument for arranging plots and tables
using the |
col_names_nicer |
if |
convert_dv_to_numeric |
logical. Should the values in the dependent variable be converted to numeric for plotting the histograms? (default = TRUE) |
holm |
if |
Value
the output will be a list of (1) ggplot object
(histogram by group) (2) a data.table with descriptive statistics by
group; and (3) a data.table with pairwise comparison results.
If save_as_png = TRUE
, the plot and tables will be also saved
on local drive as a PNG file.
Examples
## Not run:
compare_groups(data = iris, iv_name = "Species", dv_name = "Sepal.Length")
compare_groups(data = iris, iv_name = "Species", dv_name = "Sepal.Length",
x_breaks = 4:8)
## End(Not run)