Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

papaja (Preparing APA Journal Articles) is an R package that provides document formats to produce complete APA manuscripts from RMarkdown-files (PDF and Word documents) and helper functions that facilitate reporting statistics, tables, and plots.

License

NotificationsYou must be signed in to change notification settings

crsh/papaja

Repository files navigation

papaja:Prepare APA Journal Articles
with R Markdown

CRAN/METACRANProject Status: Active - The project has reached a stable, usable state and is being actively developed.GitHub last commit (main)R-CMD-checkcodecovGitHub bug issuesStackOverflow questions

SectionsExample |Installation |Usage |Getting help |Citation |papaja in the wild |Computational reproducibility |Contribute |Related R packages|Package dependencies

papaja is anaward-winning R packagethat facilitates creating computationally reproducible, submission-readymanuscripts which conform to the American Psychological Association(APA) manuscript guidelines (6th Edition).papaja provides

  • anR Markdown template that can beused with (or without)RStudio to create PDFdocuments (using theapa6 LaTeXclass) or Word documents (using a .docx-reference file).
  • Functions totypeset the results fromstatistical analyses,
  • functions to createtables, and
  • functions to createfigures in accordance with APA guidelines.

For a comprehensive introduction topapaja, see the current draft ofthemanual. If you have aspecific question that is not answered in the manual, feel free to ask aquestion on Stack Overflowusing thepapajatag. If you believeyou have found a bug or would like to request a new feature,open anissue on Github and provide aminimal complete verifiableexample.

Example

Take a look at thesourcefileof the package vignette and the resultingPDF.The vignette also contains some basic instructions.

Installation

To usepapaja you need either a recent version ofRStudio orpandoc. If youwant to create PDF- in addition to DOCX-documents you additionally needaTeX distribution. We recommendyou useTinyTex, which can be installedfrom within R:

if(!requireNamespace("tinytex",quietly=TRUE)) install.packages("tinytex")tinytex::install_tinytex()

You may also considerMikTeX for Windows,MacTeX for Mac, orTeXLive for Linux. Please refer to thepapajamanualfor detailed installation instructions.

papaja is available on CRAN but you can also install it from theGitHub repository:

# Install latest CRAN releaseinstall.packages("papaja")# Install remotes package if necessaryif(!requireNamespace("remotes",quietly=TRUE)) install.packages("remotes")# Install the stable development version from GitHubremotes::install_github("crsh/papaja")

Usage

Oncepapaja is installed, you can select the APA template whencreating a new R Markdown file through the RStudio menus.

APA template selection dialog

APA template selectiondialog

To add citations, specify your bibliography-file in the YAML frontmatter of the document (bibliography: my.bib) and start citing (fordetails, see pandoc manual on theciteprocextension. You mayalso be interested incitr, an RStudio addin to swiftly insert Markdown citations andR Studio’s visualeditor, which alsoenables swiftlyinsertingcitations.

Typeset analysis results

The functionsapa_print() andapa_table() facilitate reportingresults of your analyses. When you pass the an output object of asupported class, such as anhtest- orlm-object, toapa_print(),it will return a list of character strings that you can use to reportthe results of your analysis.

my_lm<- lm(Sepal.Width~Sepal.Length+Petal.Width+Petal.Length  ,data=iris)apa_lm<- apa_print(my_lm)apa_lm$full_result$Sepal_Length
## [1] "$b = 0.61$, 95\\% CI $[0.48, 0.73]$, $t(146) = 9.77$, $p < .001$"

papaja currently provides methods for the following object classes:

A-BD-LL-SS-Z
afex_aovdefaultlsmobjsummary.aovlist
anovaemmGridmanovasummary.glht
anova.lmeglhtmerModsummary.glm
Anova.mlmglmmixedsummary.lm
aovhtestpapaja_wscisummary.manova
aovlistlistsummary_emmsummary.ref.grid
BFBayesFactorlmsummary.Anova.mlm
BFBayesFactorToplmesummary.aov

Create tables

apa_table() may be used to produce publication-ready tables in an RMarkdown document. For instance, you might want to report some conditionmeans (with standard errors).

npk|># Summarize datadplyr::group_by(N,P)|>dplyr::summarise(mean= mean(yield)    ,se= sd(yield)/ sqrt(length(yield))    ,.groups="drop"  )|># Label columns  label_variables(N="Nitrogen"    ,P="Phosphate"    ,mean="*M*"    ,se="*SE*"  )|># Print table  apa_table(caption="Mean pea yield (with standard errors)")

Table 1.Mean pea yield (with standard errors)

NitrogenPhosphateMSE
0051.721.88
0152.422.65
1059.222.66
1156.152.08

This is a fairly simple example, butapa_table() may be used togeneratemore complex tables.

apa_table(), of course, plays nicely with the output fromapa_print(). Thus, it is possible to conveniently report completeregression tables, ANOVA tables, or the output from mixed-effectsmodels.

lm(Sepal.Width~Sepal.Length+Petal.Width+Petal.Length,data=iris)|>  apa_print()|>  apa_table(caption="Iris regression table.")

Table 2.Iris regression table.

Predictorb95% CItdfp
Intercept1.04[0.51, 1.58]3.85146< .001
Sepal Length0.61[0.48, 0.73]9.77146< .001
Petal Width0.56[0.32, 0.80]4.55146< .001
Petal Length-0.59[-0.71, -0.46]-9.43146< .001

Create figures

papaja further provides functions to create publication-ready plots.For example, you can useapa_barplot(),apa_lineplot(), andapa_beeplot() (or the general functionapa_factorial_plot()) tovisualize the results of factorial study designs:

apa_beeplot(data=stroop_data  ,dv="response_time"  ,id="id"  ,factors= c("congruency","load")  ,ylim= c(0,800)  ,dispersion=wsci# within-subjects confidence intervals  ,conf.level=.99  ,las=1)

Response times from a simulated Stroop experiment. Large dots represent condition means, small dots represent individual participants’ mean response time. Error bars represent 99% within-subjects confidence intervals.

Response times from a simulated Stroopexperiment. Large dots represent condition means, small dots representindividual participants’ mean response time. Error bars represent 99%within-subjects confidence intervals.

If you preferggplot2, trytheme_apa().

library("ggplot2")library("ggforce")p<- ggplot(stroop_data  , aes(x=congruency,y=response_time,shape=load,fill=load))+  geom_violin(alpha=0.2,color= grey(0.6))+  geom_sina(color= grey(0.6))+  stat_summary(position= position_dodge2(0.95),fun.data=mean_cl_normal)+  lims(y= c(0, max(stroop_data$response_time)))+  scale_shape_manual(values= c(21,22))+  scale_fill_grey(start=0.6,end=1)+  labs(x="Congruency"    ,y="Response time"    ,shape="Cognitive load"    ,fill="Cognitive load"  )p+ theme_apa()
## Warning: Computation failed in `stat_summary()`.## Caused by error in `fun.data()`:## ! The package "Hmisc" is required.

Usage without RStudio

Don’t use RStudio? No problem. Use thermarkdown::render function tocreate articles:

# Create new R Markdown filermarkdown::draft("mymanuscript.Rmd"  ,"apa6"  ,package="papaja"  ,create_dir=FALSE  ,edit=FALSE)# Render manuscriptrmarkdown::render("mymanuscript.Rmd")

Getting help

StackOverflow questions

For a comprehensive introduction topapaja, check out the currentdraft of thepapaja manual.If you have a specific question that is not answered in the manual, feelfree to ask a question on Stack Overflowusing thepapajatag. If you believeyou have found a bug or you want to request a new feature,open anissue on Github and provide aminimal complete verifiableexample.

Citation

Please citepapaja if you use it.

Aust, F. & Barth, M. (2024). papaja: Prepare reproducible APA journal articles with R Markdown. R package version 0.1.3. Retrieved from https://github.com/crsh/papaja

For convenience, you canusecite_r()or copy the reference information returned bycitation('papaja') toyour BibTeX file:

@Manual{,title ={{papaja}: {Prepare} reproducible {APA} journal articles with {R Markdown}},author ={Frederik Aust and Marius Barth},year ={2024},note ={R package version 0.1.3},url ={https://github.com/crsh/papaja},doi ={10.32614/CRAN.package.papaja},}

papaja in the wild

If you are interested in seeing how others are usingpapaja, you canfind acollection ofpapersand the corresponding R Markdown files in the manual.

If you have published a paper that was written withpapaja, pleaseadd the reference to thepublic Zoterogroup yourself or send usto me.

Computational reproducibility

To ensure mid- to long-term computational reproducibility we highlyrecommend conserving the software environment used to write a manuscript(e.g. R and all R packages) either in a software container or a virtualmachine. This way you can be sure that your R code does not breakbecause of updates to R or any R package. For a brief primer oncontainers and virtual machines seethe supplementarymaterialby Klein et al. (2018).

Docker is the most widely usedcontainerization approach. It is open source and free to use butrequires some disk space. CodeOcean is a commercial service that buildson Docker, facilitates setting up and sharing containers and lets yourun computations in the cloud. See thepapaja manual onhow to getstarted usingpapaja with Docker orCodeOceanandour Docker workflowtailored for easy use withpapaja.

Contribute

GitHub help wanted issuesGitHub documentation issues

Likepapaja and want to contribute? We highly appreciate anycontributions to the R package or its documentation. Take a look at theopen issues if you needinspiration. There are many additional analyses that we would likeapa_print() to support. Any new S3/S4-methods for this function arealways appreciated (e.g.,factanal,fa,lavaan). For a primer onadding newapa_print()-methods, see the getting-started-vignette:

vignette("extending_apa_print",package="papaja")

Before working on a contribution, please review our briefcontributingguidelinesandcode ofconduct.

Related R packages

By now, there are a couple of R packages that provide conveniencefunctions to facilitate the reporting of statistics in accordance withAPA guidelines.

  • apa: Format output ofstatistical tests in R according to APA guidelines
  • APAstats: R functionsfor formatting results in APA style and other stuff
  • apaTables: CreateAmerican Psychological Association (APA) Style Tables
  • rempsyc: Conveniencefunctions for psychology
  • sigr: Concise formatting ofsignificances in R
  • apaquarto: A quartoextension for creating APA7 documents in .docx, .html, and .pdfformats

If you are looking for other journal article templates, you may beinterested in therticlespackage.

Package dependencies

About

papaja (Preparing APA Journal Articles) is an R package that provides document formats to produce complete APA manuscripts from RMarkdown-files (PDF and Word documents) and helper functions that facilitate reporting statistics, tables, and plots.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors11


[8]ページ先頭

©2009-2025 Movatter.jp