apa_print.htest {papaja} | R Documentation |
Typeset Statistical Results from Hypothesis Tests
Description
Takes htest
objects from various statistical methods (e.g., t.test()
,
wilcox.test()
, cor.test()
) to create formatted character strings to
report the results in accordance with APA manuscript guidelines.
Usage
## S3 method for class 'htest'
apa_print(
x,
stat_name = NULL,
est_name = NULL,
n = NULL,
conf.int = NULL,
in_paren = FALSE,
...
)
Arguments
x |
An |
stat_name |
Character. If |
est_name |
Character. If |
n |
Numeric. Sample size; required when reporting |
conf.int |
Numeric. If |
in_paren |
Logical. Whether the formatted string is to be reported in
parentheses. If |
... |
Arguments passed on to |
Details
The function should work on a wide range of htest
objects. Due to the
large number of functions that produce these objects and their
idiosyncrasies, the returned strings should be compared to the original
object. If you experience inaccuracies you may report these
[here]https://github.com/crsh/papaja/issues (please include
a reproducible example in your report).
stat_name
and est_name
are placed in the output string and are thus
passed to pandoc or LaTeX through knitr. Thus, to the extent it is
supported by the final document type, you can pass LaTeX-markup to format
the final text (e.g., \\tau
yields \tau
).
Value
apa_print()
-methods return a named list of class apa_results
containing the following elements:
estimate |
One or more character strings giving point estimates, confidence intervals, and confidence level. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is |
statistic |
One or more character strings giving the test statistic, parameters (e.g., degrees of freedom), and p-value. A single string is returned in a vector; multiple strings are returned as a named list. If no estimate is available the element is |
full_result |
One or more character strings comprised 'estimate' and 'statistic'. A single string is returned in a vector; multiple strings are returned as a named list. |
table |
A |
Column names in apa_results_table
are standardized following the broom glossary (e.g., term
, estimate
conf.int
, statistic
, df
, df.residual
, p.value
). Additionally, each column is labelled (e.g., $\hat{\eta}^2_G$
or $t$
) using the tinylabels package and these labels are used as column names when an apa_results_table
is passed to apa_table()
.
See Also
Other apa_print:
apa_print.BFBayesFactor()
,
apa_print.aov()
,
apa_print.emmGrid()
,
apa_print.glht()
,
apa_print.list()
,
apa_print.lme()
,
apa_print.lm()
,
apa_print.merMod()
,
apa_print()
Examples
# Comparisons of central tendencies
t_stat <- t.test(extra ~ group, data = sleep)
apa_print(t_stat)
apa_print(t_stat, stat_name = "tee")
wilcox_stat <- wilcox.test(extra ~ group, data = sleep, exact = FALSE)
apa_print(wilcox_stat)
# Correlations
## Data from Hollander & Wolfe (1973), p. 187f.
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_stat <- cor.test(x, y, method = "spearman")
apa_print(cor_stat)
# Contingency tables
## Data from Fleiss (1981), p. 139.
smokers <- c(83, 90, 129, 70)
patients <- c(86, 93, 136, 82)
prop_stat <- prop.test(smokers, patients)
apa_print(prop_stat, n = sum(patients))