papaja (version 0.1.0.9842)

apa_print.htest: Format statistics (APA 6th edition)

Description

Takes htest objects from various statistical methods to create formatted character strings to report the results in accordance with APA manuscript guidelines.

Usage

apa_print.htest(x, stat_name = NULL, est_name = NULL, n = NULL,
  ci = NULL, in_paren = FALSE, ...)

Arguments

x

htest object. See details.

stat_name

Character. If NULL (default) the name given in x (or a formally correct adaptation, such as \(\chi^2\) instead of "x-squared") is used for the test statistic, otherwise the supplied name is used. See details.

est_name

Character. If NULL (default) the name given in x (or a formally correct adaptation, such as \(r_S\) instead of "rho") is used for the estimate, otherwise the supplied name is used. See details.

n

Numeric. Size of the sample; required when reporting \(\chi^2\) tests, otherwise this parameter is ignored.

ci

Numeric. If NULL (default) the function tries to obtain confidence intervals from x. Other confidence intervals can be supplied as a vector of length 2 (lower and upper boundary, respectively) with attribute conf.level, e.g., when calculating bootstrapped confidence intervals.

in_paren

Logical. Indicates if the formatted string will be reported inside parentheses. See details.

...

Arguments passed on to printnum

x

Numeric. Can be either a single value, vector, or matrix.

Value

apa_print() returns a list containing the following components according to the input:

statistic

A character string giving the test statistic, parameters (e.g., degrees of freedom), and p value.

estimate

A character string giving the descriptive estimates and confidence intervals if possible

% , either in units of the analyzed scale or as standardized effect size.
full_result

A joint character string comprised of estimate and statistic.

table

A data.frame, which can be passed to apa_table.

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 produced strings may sometimes be inaccurate. If you experience inaccuracies you may report these here (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 kntir. 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\)).

If in_paren is TRUE parentheses in the formatted string, such as those surrounding degrees of freedom, are replaced with brackets.

See Also

Other apa_print: apa_print.BFBayesFactor, apa_print.aov, apa_print.emmGrid, apa_print.glht, apa_print.glm, apa_print.list, apa_print

Examples

Run this code
# NOT RUN {
# Comparisions 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)
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))
# }

Run the code above in your browser using DataLab