Movatterモバイル変換


[0]ホーム

URL:


Introduction to apa

Daniel Gromer

2023-10-06

The*_apa() functions help you to format outputs ofstatistical tests according to guidelines of the APA (AmericanPsychological Association).

The functions take the return value of a test function as the firstargument, e.g. a call tochisq.test() is passed tochisq_apa(), which returns a formatted string.

The idea of such formatters was introduced in theschoRschpackage. apa generalizes this idea by providing formatters fordifferent output formats (text, Markdown, RMarkdown, HTML, LaTeX, LaTeXinline math, docx and R’s plotmath syntax).

Currently supported tests are:

Example

Take the following test of a correlation as an example:

# Data from ?cor.testx<-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)ct<-cor.test(x, y)ct
## ##  Pearson's product-moment correlation## ## data:  x and y## t = 1.8411, df = 7, p-value = 0.1082## alternative hypothesis: true correlation is not equal to 0## 95 percent confidence interval:##  -0.1497426  0.8955795## sample estimates:##       cor ## 0.5711816

Callingcor_apa() then returns a string ready tocopy-and-paste into manuscripts or presentations.

cor_apa(ct)
## r(7) = .57, p = .108

Theformat argument ofcor_apa() allows youto specify the output format, which can be one of"text"(default),"markdown","rmarkdown","html","latex","latex_math","docx" or"plotmath".

cor_apa(ct,format ="rmarkdown")
## *r*(7) = .57, *p* = .108

Which is printed asr(7) = .57,p = .108 in aRMarkdown document.

cor_apa(ct,format ="latex")
## \textit{r}(7)~=~.57, \textit{p}~=~.108
# Opens a temporary document in your word processorcor_apa(ct,format ="docx")

# Paste output in a plot using R's plotmath syntaxplot(x, y)abline(lm(y~ x))text(55,3.9,cor_apa(ct,format ="plotmath"))


[8]ページ先頭

©2009-2025 Movatter.jp