cohen_d_over_n: Cohen's d as a function of sample size

View source: R/cohen_d_over_n.R

cohen_d_over_nR Documentation

Cohen's d as a function of sample size

Description

Plot Cohen's d as sample size increases.

Usage

cohen_d_over_n(
  data = NULL,
  iv_name = NULL,
  dv_name = NULL,
  save_as_png = FALSE,
  png_name = NULL,
  xlab = NULL,
  ylab = NULL,
  width = 16,
  height = 9
)

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)

save_as_png

if save = TRUE, the plot will be saved as a PNG file.

png_name

name of the PNG file to be saved. By default, the name will be "cohen_d_over_n_" 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 xlab = FALSE, the title will be removed. By default (i.e., if no input is given), dv_name will be used as the title.

ylab

title of the y-axis for the histogram by group. If ylab = FALSE, the title will be removed. By default (i.e., if no input is given), iv_name will be used as the title.

width

width of the plot to be saved. This argument will be directly entered as the width argument for the ggsave function within ggplot2 package (default = 16)

height

height of the plot to be saved. This argument will be directly entered as the height argument for the ggsave function within ggplot2 package (default = 9)

Value

the output will be a list of (1) ggplot object (histogram by group) and (2) a data.table with Cohen's d by sample size

Examples

## Not run: 
cohen_d_over_n(data = mtcars, iv_name = "am", dv_name = "mpg")

## End(Not run)

kim documentation built on Oct. 9, 2023, 5:08 p.m.