Title: | Create R Markdown Text for Results in the Style of the American Psychological Association (APA) |
---|---|
Description: | Create APA style text from analyses for use within R Markdown documents. Descriptive statistics, confidence intervals, and cell sizes are reported. |
Authors: | David Stanley [aut, cre] |
Maintainer: | David Stanley <[email protected]> |
License: | MIT License + file LICENSE |
Version: | 0.1.7 |
Built: | 2025-02-13 02:41:14 UTC |
Source: | https://github.com/dstanley4/apatext |
Report descriptive statistics for a set of values
apa.desc( .data, .dv = NULL, show.mean = NULL, show.sd = NULL, show.se = NULL, show.conf.interval = NULL, show.N = NULL, number.decimals = NULL )
apa.desc( .data, .dv = NULL, show.mean = NULL, show.sd = NULL, show.se = NULL, show.conf.interval = NULL, show.N = NULL, number.decimals = NULL )
.data |
A data frame or data frame extension (e.g., tibble) |
.dv |
Name of the dependent variable column |
show.mean |
Show mean (Bool. Default TRUE) |
show.sd |
Show standard deviation (Bool. Default TRUE) |
show.se |
Show standard error (Bool. Default FALSE) |
show.conf.interval |
Show confidence interval (Bool. Default TRUE) |
show.N |
Show number of cases (Bool. Default TRUE) |
number.decimals |
Number of decimals in output |
R Markdown text
# 2-way ANOVA Example if (requireNamespace("apaTables", quietly = TRUE)){ library(dplyr) goggles <- apaTables::goggles #Main Effect Means: Gender goggles %>% filter(gender == "Female") %>% apa.desc(attractiveness) goggles %>% filter(gender == "Male") %>% apa.desc(attractiveness) # Main Effect Means: Alcohol goggles %>% filter(alcohol == "None") %>% apa.desc(attractiveness) goggles %>% filter(alcohol == "2 Pints") %>% apa.desc(attractiveness) goggles %>% filter(alcohol == "4 Pints") %>% apa.desc(attractiveness) # Single Cell Mean goggles %>% filter(alcohol == "4 Pints", gender == "Female") %>% apa.desc(attractiveness) }
# 2-way ANOVA Example if (requireNamespace("apaTables", quietly = TRUE)){ library(dplyr) goggles <- apaTables::goggles #Main Effect Means: Gender goggles %>% filter(gender == "Female") %>% apa.desc(attractiveness) goggles %>% filter(gender == "Male") %>% apa.desc(attractiveness) # Main Effect Means: Alcohol goggles %>% filter(alcohol == "None") %>% apa.desc(attractiveness) goggles %>% filter(alcohol == "2 Pints") %>% apa.desc(attractiveness) goggles %>% filter(alcohol == "4 Pints") %>% apa.desc(attractiveness) # Single Cell Mean goggles %>% filter(alcohol == "4 Pints", gender == "Female") %>% apa.desc(attractiveness) }
Report descriptive statistics for a set of values
apa.ind.t.test( .data, .iv, .dv, bonferroni.multiplier = 1, show.mean.difference = TRUE, show.statistic = NULL, show.conf.interval = NULL, number.decimals = NULL, number.decimals.p = NULL, var.equal = TRUE, one.sided = FALSE )
apa.ind.t.test( .data, .iv, .dv, bonferroni.multiplier = 1, show.mean.difference = TRUE, show.statistic = NULL, show.conf.interval = NULL, number.decimals = NULL, number.decimals.p = NULL, var.equal = TRUE, one.sided = FALSE )
.data |
A data frame or data frame extension (e.g., tibble) |
.iv |
Name of the independent variable column (only 2 levels) |
.dv |
Name of the dependent variable column |
bonferroni.multiplier |
Multiply the p-value by this number to make a bonferroni adjustment |
show.mean.difference |
Show mean difference (Bool. Default TRUE) |
show.statistic |
Show t-value (Bool. Default TRUE) |
show.conf.interval |
Show CI for mean difference (Bool. Default TRUE) |
number.decimals |
Number of decimals used in output (excluding p-value) |
number.decimals.p |
Number of decimals used in p-value output |
var.equal |
(boolean) TRUE or FALSE for cell equal variances |
one.sided |
(boolean) TRUE or FALSE for conducting a one-sided test |
R Markdown text
if (requireNamespace("apaTables", quietly = TRUE)){ library(dplyr) goggles <- apaTables::goggles # one-sided test goggles %>% filter(alcohol == "None") %>% filter(gender == "Female" | gender == "Male") %>% apa.ind.t.test(gender, attractiveness, var.equal = TRUE, one.sided = TRUE) #two-sided test goggles %>% filter(alcohol == "None") %>% filter(gender == "Female" | gender == "Male") %>% apa.ind.t.test(gender, attractiveness, var.equal = TRUE, one.sided = FALSE) #two-sided test with Bonferroni correction (three exploratory tests) goggles %>% filter(alcohol == "None") %>% filter(gender == "Female" | gender == "Male") %>% apa.ind.t.test(gender, attractiveness, var.equal = TRUE, one.sided = FALSE, bonferroni.multiplier = 3) }
if (requireNamespace("apaTables", quietly = TRUE)){ library(dplyr) goggles <- apaTables::goggles # one-sided test goggles %>% filter(alcohol == "None") %>% filter(gender == "Female" | gender == "Male") %>% apa.ind.t.test(gender, attractiveness, var.equal = TRUE, one.sided = TRUE) #two-sided test goggles %>% filter(alcohol == "None") %>% filter(gender == "Female" | gender == "Male") %>% apa.ind.t.test(gender, attractiveness, var.equal = TRUE, one.sided = FALSE) #two-sided test with Bonferroni correction (three exploratory tests) goggles %>% filter(alcohol == "None") %>% filter(gender == "Female" | gender == "Male") %>% apa.ind.t.test(gender, attractiveness, var.equal = TRUE, one.sided = FALSE, bonferroni.multiplier = 3) }
Report r(x,y) correlation in markdown APA style
apa.r( .data, .x, .y, alternative = "two.sided", method = "pearson", show.r = TRUE, show.conf.interval = NULL, show.N = NULL, show.p = NULL, show.statistic = NULL, number.decimals = NULL, number.decimals.p = NULL )
apa.r( .data, .x, .y, alternative = "two.sided", method = "pearson", show.r = TRUE, show.conf.interval = NULL, show.N = NULL, show.p = NULL, show.statistic = NULL, number.decimals = NULL, number.decimals.p = NULL )
.data |
A data frame or data frame extension (e.g., tibble) |
.x |
Name of column in data frame |
.y |
Name of column in data frame |
alternative |
Alternative hypothesis to pass to alternative argument of cor.test. Default is "two.sided" |
method |
Calculation method to pass to alternative argument of cor.test. Default is "pearson" |
show.r |
Show correlation or not (TRUE/FALSE) |
show.conf.interval |
Show confidence interval or not (TRUE/FALSE). Default behavior is TRUE. |
show.N |
Show sample size or not (TRUE/FALSE). Default behavior is TRUE. |
show.p |
Show p-value or not (TRUE/FALSE). Default behavior is TRUE. |
show.statistic |
Show test statistic or not (TRUE/FALSE). Default behavior is TRUE. |
number.decimals |
Number of decimals used in output (excluding p-value) |
number.decimals.p |
Number of decimals used in output for p-value |
R Markdown text
library(dplyr) attitude %>% apa.r(rating, advance)
library(dplyr) attitude %>% apa.r(rating, advance)
Report difference between correlations in markdown APA style from different samples
apa.r.compare.across.samples( formula, data1, data2, alternative = "two.sided", show.conf.interval = NULL, show.N = NULL, show.p = NULL, show.statistic = NULL )
apa.r.compare.across.samples( formula, data1, data2, alternative = "two.sided", show.conf.interval = NULL, show.N = NULL, show.p = NULL, show.statistic = NULL )
formula |
Formula for comparing correlations |
data1 |
Project data frame 1 name |
data2 |
Project data frame 2 name |
alternative |
Alternative hypothesis to pass to alternative argument of cocor.indep.groups. Default is "two.sided" |
show.conf.interval |
Show confidence interval or not (TRUE/FALSE). Default behavior is TRUE. |
show.N |
Show sample size or not (TRUE/FALSE). Default behavior is TRUE. |
show.p |
Show p-value or not (TRUE/FALSE). Default behavior is TRUE. |
show.statistic |
Show test statistic or not (TRUE/FALSE). Default behavior is TRUE. |
R Markdown text
# Test difference between r(rating, learning) from dataset: attitude # and r(weight, height) from dataset: women apa.r.compare.across.samples(formula = ~ rating + learning | height + weight, data1 = attitude, data2 = women)
# Test difference between r(rating, learning) from dataset: attitude # and r(weight, height) from dataset: women apa.r.compare.across.samples(formula = ~ rating + learning | height + weight, data1 = attitude, data2 = women)
Report difference between correlations in markdown APA style from different samples
apa.r.compare.across.samples.from.descriptive( r1, r2, n1, n2, alternative = "two.sided", show.conf.interval = NULL, show.N = NULL, show.p = NULL, show.statistic = NULL )
apa.r.compare.across.samples.from.descriptive( r1, r2, n1, n2, alternative = "two.sided", show.conf.interval = NULL, show.N = NULL, show.p = NULL, show.statistic = NULL )
r1 |
Correlation in sample 1 |
r2 |
Correlation in sample 2 |
n1 |
Sample size for sample 1 |
n2 |
Sample size for sample 2 |
alternative |
Alternative hypothesis to pass to alternative argument of cocor.indep.groups. Default is "two.sided" |
show.conf.interval |
Show confidence interval or not (TRUE/FALSE). Default behavior is TRUE. |
show.N |
Show sample size or not (TRUE/FALSE). Default behavior is TRUE. |
show.p |
Show p-value or not (TRUE/FALSE). Default behavior is TRUE. |
show.statistic |
Show test statistic or not (TRUE/FALSE). Default behavior is TRUE. |
R Markdown text
apa.r.compare.across.samples.from.descriptive(r1 = .3, r2 =.6, n1 = 70, n2 =80)
apa.r.compare.across.samples.from.descriptive(r1 = .3, r2 =.6, n1 = 70, n2 =80)
Report difference in markdown APA style between between correlations within a sample
apa.r.compare.within.sample( formula, data, test = "pearson1898", alternative = "two.sided", show.conf.interval = NULL, show.N = NULL, show.p = NULL, show.statistic = NULL )
apa.r.compare.within.sample( formula, data, test = "pearson1898", alternative = "two.sided", show.conf.interval = NULL, show.N = NULL, show.p = NULL, show.statistic = NULL )
formula |
Formula for comparing correlations |
data |
Project data frame name |
test |
Type of significance test. If non-overlapping variables use one of "pearson1898", "dunn1969", "steiger1980", "raghunathan1996", or "silver2004". If overlapping variables use one of pearson1898, hotelling1940, hendrickson1970, williams1959, olkin1967, dunn1969, steiger1980, meng1992, hittner2003. Default is pearson1898. |
alternative |
Alternative hypothesis to pass to alternative argument of cor.test. Default is "two.sided" |
show.conf.interval |
Show confidence interval or not (TRUE/FALSE). Default behavior is TRUE. |
show.N |
Show sample size or not (TRUE/FALSE). Default behavior is TRUE. |
show.p |
Show p-value or not (TRUE/FALSE). Default behavior is TRUE. |
show.statistic |
Show test statistic or not (TRUE/FALSE). Default behavior is TRUE. |
R Markdown text
# non-overlappling variables example apa.r.compare.within.sample(data = attitude, formula = ~ rating + complaints | privileges + learning) # overlappling variables example apa.r.compare.within.sample(data = attitude, formula = ~ rating + complaints | rating + learning)
# non-overlappling variables example apa.r.compare.within.sample(data = attitude, formula = ~ rating + complaints | privileges + learning) # overlappling variables example apa.r.compare.within.sample(data = attitude, formula = ~ rating + complaints | rating + learning)
Create APA style text from analyses for use within R Markdown documents. Descriptive statistics, confidence intervals, and cell sizes are reported.
Package: | apaText |
Type: | Package |
Version: | 0.1.7 |
Date: | 2023-05-23 |
License: | MIT |
Author: | David J. Stanley [email protected] |
Maintainer: | David J. Stanley [email protected] |
Create apaText default options for showing confidence intervals etc.. These options will be used unless overridden by local function arguments
set.apa.default.options()
set.apa.default.options()
A list with options object for apaText
# You must create an object called apa.default.options # for options to be used, as per below. apa.options <- set.apa.default.options()
# You must create an object called apa.default.options # for options to be used, as per below. apa.options <- set.apa.default.options()