| Type: | Package | 
| Title: | Format Outputs of Statistical Tests According to APA Guidelines | 
| Version: | 0.3.4 | 
| Description: | Formatter functions in the 'apa' package take the return value of a statistical test function, e.g. a call to chisq.test() and return a string formatted according to the guidelines of the APA (American Psychological Association). | 
| URL: | https://github.com/dgromer/apa | 
| BugReports: | https://github.com/dgromer/apa/issues | 
| License: | GPL (≥ 3) | 
| Depends: | R (≥ 3.1.0) | 
| Imports: | dplyr (≥ 0.4), magrittr, MBESS, purrr, rmarkdown, stringr, tibble | 
| Suggests: | afex (≥ 0.14), ez, testthat, knitr | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.2.3 | 
| VignetteBuilder: | knitr | 
| NeedsCompilation: | no | 
| Packaged: | 2023-10-06 14:22:56 UTC; dag76yu | 
| Author: | Daniel Gromer [aut, cre] | 
| Maintainer: | Daniel Gromer <dgromer@mailbox.org> | 
| Repository: | CRAN | 
| Date/Publication: | 2023-10-06 15:00:02 UTC | 
Report ANOVA in APA style
Description
Report ANOVA in APA style
Usage
anova_apa(
  x,
  effect = NULL,
  sph_corr = c("greenhouse-geisser", "gg", "huynh-feldt", "hf", "none"),
  force_sph_corr = FALSE,
  es = c("petasq", "pes", "getasq", "ges"),
  format = c("text", "markdown", "rmarkdown", "html", "latex", "latex_math", "docx",
    "plotmath"),
  info = FALSE,
  print = TRUE
)
Arguments
x | 
 A call to   | 
effect | 
 Character string indicating the name of the effect to display.
If is   | 
sph_corr | 
 Character string indicating the method used for correction if
the assumption of sphericity is violated (only applies to repeated-measures
and mixed design ANOVA). Can be one of   | 
force_sph_corr | 
 Logical indicating if sphericity correction should be
applied to all within factors regardless of what the result of Mauchly's
test of sphericity is (default is   | 
es | 
 Character string indicating the effect size to display in the
output, one of   | 
format | 
 Character string specifying the output format. One of
  | 
info | 
 Logical indicating whether to print a message on the used test
(default is   | 
print | 
 Logical indicating whether to print the formatted output via
  | 
Examples
# Using the ez package
library(ez)
data(ANT)
x <- ezANOVA(ANT[ANT$error==0,], dv = rt, wid = subnum,
             within = c(cue, flank), between = group, detailed = TRUE)
anova_apa(x)
# Using the afex package
library(afex)
data(md_12.1)
y <- aov_ez(id = "id", dv = "rt", data = md_12.1,
            within = c("angle", "noise"))
anova_apa(y)
APA Formatting for RMarkdown Reports
Description
A wrapper around the *_apa functions, providing a convenient way to
use the formatters in inline code in RMarkdown documents.
Usage
apa(x, effect = NULL, format = "rmarkdown", print = FALSE, ...)
Arguments
x | 
 An R object. Must be a call to one of   | 
effect | 
 (only applicable if   | 
format | 
 Character string specifying the output format. One of
  | 
print | 
 Logical indicating whether to return the result as an R object
(  | 
... | 
 Further arguments passed to other methods  | 
See Also
anova_apa, chisq_apa, cor_apa, t_apa
Report Chi-squared test in APA style
Description
Report Chi-squared test in APA style
Usage
chisq_apa(
  x,
  print_n = FALSE,
  format = c("text", "markdown", "rmarkdown", "html", "latex", "latex_math", "docx",
    "plotmath"),
  info = FALSE,
  print = TRUE
)
Arguments
x | 
 A call to   | 
print_n | 
 Logical indicating whether to show sample size in text  | 
format | 
 Character string specifying the output format. One of
  | 
info | 
 Logical indicating whether to print a message on the used test
(default is   | 
print | 
 Logical indicating whether to print the formatted output via
  | 
Examples
# Example data from ?chisq.test
m <- rbind(c(762, 327, 468), c(484, 239, 477))
chisq_apa(chisq.test(m))
Cohen's d
Description
Calculate Cohen's d from raw data or a call to t_test/t.test.
Usage
cohens_d(...)
## Default S3 method:
cohens_d(
  x,
  y = NULL,
  paired = FALSE,
  corr = c("none", "hedges_g", "glass_delta"),
  na.rm = FALSE,
  ...
)
## S3 method for class 'data.frame'
cohens_d(
  data,
  dv,
  iv,
  paired = FALSE,
  corr = c("none", "hedges_g", "glass_delta"),
  na.rm = FALSE,
  ...
)
## S3 method for class 'formula'
cohens_d(
  formula,
  data,
  corr = c("none", "hedges_g", "glass_delta"),
  na.rm = FALSE,
  ...
)
## S3 method for class 'htest'
cohens_d(ttest, corr = c("none", "hedges_g", "glass_delta"), ...)
Arguments
... | 
 Further arguments passed to methods.  | 
x | 
 A (non-empty) numeric vector of data values.  | 
y | 
 An optional (non-empty) numeric vector of data values.  | 
paired | 
 A logical indicating whether Cohen's d should be calculated for a paired sample or two independent samples (default). Ignored when calculating Cohen's for one sample.  | 
corr | 
 Character specifying the correction applied to calculation of the
effect size:   | 
na.rm | 
 Logical. Should missing values be removed?  | 
data | 
 A data frame containing either the variables in the formula
  | 
dv | 
 Character indicating the name of the column in   | 
iv | 
 Character indicating the name of the column in   | 
formula | 
 A formula of the form   | 
ttest | 
 An object of class   | 
Details
To calculate Cohen's d from summary statistics (M, SD, ..) use cohens_d_.
References
Lakens, D. (2013). Calculating and reporting effect sizes to facilitate cumulative science: a practical primer for t-tests and ANOVAs. Frontiers in Psychology, 4, 863. doi:10.3389/fpsyg.2013.00863
Examples
# Calculate from raw data
cohens_d(c(10, 15, 11, 14, 17), c(22, 18, 23, 25, 20))
# Methods when working with data frames
cohens_d(sleep, dv = extra, iv = group, paired = TRUE)
# or
cohens_d(sleep, dv = "extra", iv = "group", paired = TRUE)
# formula interface
sleep2 <- reshape(sleep, direction = "wide", idvar = "ID", timevar = "group")
cohens_d(Pair(extra.1, extra.2) ~ 1, sleep2, paired = TRUE)
# Or pass a call to t_test or t.test
cohens_d(t_test(Pair(extra.1, extra.2) ~ 1, sleep2))
Cohen's d
Description
Calculate Cohens'd from different statistics (see Details).
Usage
cohens_d_(
  m1 = NULL,
  m2 = NULL,
  sd1 = NULL,
  sd2 = NULL,
  n1 = NULL,
  n2 = NULL,
  t = NULL,
  n = NULL,
  paired = FALSE,
  corr = c("none", "hedges_g", "glass_delta")
)
Arguments
m1 | 
 Numeric, mean of the first group  | 
m2 | 
 Numeric, mean of the second group  | 
sd1 | 
 Numeric, standard deviation of the first group  | 
sd2 | 
 Numeric, standard deviation of the second group  | 
n1 | 
 Numeric, size of the first group  | 
n2 | 
 Numeric, size of the second group  | 
t | 
 Numeric, t-test statistic  | 
n | 
 Numeric, total sample size  | 
paired | 
 Logical indicating whether to calculate Cohen's for independent
samples or one sample (  | 
corr | 
 Character specifying the correction applied to calculation of the
effect size:   | 
Details
The following combinations of statistics are possible:
-  
m1,m2,sd1,sd2,n1andn2 -  
t,n1andn2 -  
tandn 
References
Lakens, D. (2013). Calculating and reporting effect sizes to facilitate cumulative science: a practical primer for t-tests and ANOVAs. Frontiers in Psychology, 4, 863. doi:10.3389/fpsyg.2013.00863
Report Correlation in APA style
Description
Report Correlation in APA style
Usage
cor_apa(
  x,
  r_ci = FALSE,
  format = c("text", "markdown", "rmarkdown", "html", "latex", "latex_math", "docx",
    "plotmath"),
  info = FALSE,
  print = TRUE
)
Arguments
x | 
 A call to   | 
r_ci | 
 Logical indicating whether to display the confidence interval
for the correlation coefficient (default is   | 
format | 
 Character string specifying the output format. One of
  | 
info | 
 Logical indicating whether to print a message on the used test
(default is   | 
print | 
 Logical indicating whether to print the formatted output via
  | 
Examples
# Example data from ?cor.test
x <- c(44.4, 45.9, 41.9, 53.3, 44.7, 44.1, 50.7, 45.2, 60.1)
y <- c( 2.6,  3.1,  2.5,  5.0,  3.6,  4.0,  5.2,  2.8,  3.8)
cor_apa(cor.test(x, y))
# Spearman's rho
cor_apa(cor.test(x, y, method = "spearman"))
# Kendall's tau
cor_apa(cor.test(x, y, method = "kendall"))
Partial Eta Squared
Description
Partial Eta Squared
Usage
petasq(x, effect)
Arguments
x | 
 A call to   | 
effect | 
 Character string indicating the name of the effect for which the partial eta squared should be returned.  | 
Partial Eta Squared
Description
Calculate the partial eta squared effect size from sum of squares.
\eta_p^2 = \frac{SS_effect}{SS_effect + SS_error}
Usage
petasq_(ss_effect, ss_error)
Arguments
ss_effect | 
 numeric, sum of squares of the effect  | 
ss_error | 
 numeric, sum of squares of the corresponding error  | 
Report t-Test in APA style
Description
Report t-Test in APA style
Usage
t_apa(
  x,
  es = "cohens_d",
  es_ci = FALSE,
  format = c("text", "markdown", "rmarkdown", "html", "latex", "latex_math", "docx",
    "plotmath"),
  info = FALSE,
  print = TRUE
)
Arguments
x | 
 A call to   | 
es | 
 Character specifying the effect size to report. One of
  | 
es_ci | 
 Logical indicating whether to add the 95
for Cohen's d (experimental; default is   | 
format | 
 Character string specifying the output format. One of
  | 
info | 
 Logical indicating whether to print a message on the used test
(default is   | 
print | 
 Logical indicating whether to print the formatted output via
  | 
Examples
# Two independent samples t-test
t_apa(t_test(1:10, y = c(7:20)))
# Two dependent samples t-test
sleep2 <- reshape(sleep, direction = "wide", idvar = "ID", timevar = "group")
t_apa(t_test(Pair(extra.1, extra.2) ~ 1, sleep2))
Student's t-Test
Description
A wrapper for t.test which includes the original data in the returned
object.
Usage
t_test(x, ...)
## Default S3 method:
t_test(
  x,
  y = NULL,
  alternative = c("two.sided", "less", "greater"),
  mu = 0,
  paired = FALSE,
  var.equal = FALSE,
  conf.level = 0.95,
  ...
)
## S3 method for class 'formula'
t_test(formula, data, subset, na.action, ...)
Arguments
x | 
 a (non-empty) numeric vector of data values.  | 
... | 
 further arguments to be passed to or from methods.  | 
y | 
 an optional (non-empty) numeric vector of data values.  | 
alternative | 
 a character string specifying the alternative
hypothesis, must be one of   | 
mu | 
 a number indicating the true value of the mean (or difference in means if you are performing a two sample test).  | 
paired | 
 a logical indicating whether you want a paired t-test.  | 
var.equal | 
 a logical variable indicating whether to treat the
two variances as being equal. If   | 
conf.level | 
 confidence level of the interval.  | 
formula | 
 a formula of the form   | 
data | 
 an optional matrix or data frame (or similar: see
  | 
subset | 
 an optional vector specifying a subset of observations to be used.  | 
na.action | 
 a function which indicates what should happen when
the data contain   |