9 Customizations

9.1 Author name disambiguation

As per APA style, citations in papaja documents will be disambiguated if the bibliography file contains multiple authors with the same family but different given names. This can be a nuisance if the bibliographic information is not maintained meticulously. Entries such as author = {John Doe} and author = {J. Doe} are taken to be different authors and will be disambiguated (i.e. “John Doe (1986)” and “J. Doe (1986)”).

papaja provides an APA CSL file that disables author name disambiguation. To use this variant insert the following into YAML front matter:

disambiguate_authors: no

Note that using this style can create the false impression that two works are authored by the same author when really they were not. For example, author = {John Doe} and author = {Jane Doe} will be displayed as “Doe (1986a)” and “Doe (1986b).”

If you prefer \(\LaTeX\) to render the bibliographic information, we recommend the following approach to disable author name disambiguation:

lang              : "en-EN" # Optional, added for clarity

biblio-style      : "apa"
biblatexoptions   : "uniquename=false"
header-includes:
  - \DeclareLanguageMapping{english}{english-apa}

output:
  papaja::apa6_pdf:
    citation_package: biblatex

Specifying lang is optional in this case, because en-EN is the default. pandoc converts en-EN to english and inserts it into the document preamble. Hence, english needs to be mapped to english-apa. Similarly, if you want, say, British English you would have to adapt the above as follows:

lang              : "en-GB" # Required
header-includes:
  - \DeclareLanguageMapping{british}{british-apa}

A general drawback to this approach is that biblatex does not operate on any text in the YAML front matter. This can be a problem when, for example, the abstract contains citations. Fortunately, this drawback can be resolved by defining the respective text for the YAML front matter as a Text references. Replace the text of the abstract in the YAML front matter by a unique identifier:

abstract: (ref:abstract)

(ref:abstract) is a stand-in for text that you define in the body of the R Markdown document (e.g., right after the YAML front matter):

(ref:abstract) This is the abstract [@doe1986].

This text will now be processed and citations will be generated as expected. For details see Text references.

9.2 Adjusting line spacing

According to the APA guidelines, “Tables may be submitted either single- or double-spaced.” [p. 141; American Psychological Association (2010)]. Adjusting the line spacing of table contents is currently not supported in papaja. However, as usual it is possible to adjust the spacing in PDF documents by including additional \(\LaTeX\) code. If you use apa_table(), including the following in the YAML front matter will result in single-spaced tables with double-spaced caption and table note:

header-includes:
  - \usepackage{setspace}
  - \AtBeginEnvironment{tabular}{\singlespacing}
  - \AtBeginEnvironment{lltable}{\singlespacing}
  - \AtBeginEnvironment{tablenotes}{\doublespacing}
  - \captionsetup[table]{font={stretch=1.5}}
  - \captionsetup[figure]{font={stretch=1.5}}

Similarly, the line spacing of figure captions can be adjusted as follows:

header-includes:
  - \usepackage{setspace}
  - \AtBeginEnvironment{tabular}{\doublespacing}
  - \AtBeginEnvironment{lltable}{\doublespacing}
  - \AtBeginEnvironment{tablenotes}{\doublespacing}
  - \captionsetup[table]{font={stretch=1.5}}
  - \captionsetup[figure]{font={stretch=1}}

9.3 Writing dissertations

While papaja is primarily intended for preparing journal articles and preprints, it is possible to create entire dissertations using it. This is particularly useful for cumulative dissertation formats that include individual papers as separate chapters. If the individual papers were written with papaja, it is straight forward to include them in the dissertation document. The first dissertation written using papaja that I’m aware of is Contingency Awareness in Evaluative Conditioning: Investigations Using Subliminal Stimulus Presentations by Heycke (2018). Tobias provides a brief tutorial on how he used papaja.

9.4 Customizing apa_print()

apa_print() is designed to format the results from various statistical methods in accordance with APA guidelines. Of course, one size does not fit all and maybe you would like to report other or additional information. This section will demonstrate how to use glue_apa_results() to customize the output of apa_print().

library("afex")
## Loading required package: lme4
## Loading required package: Matrix
## ************
## Welcome to afex. For support visit: http://afex.singmann.science/
## - Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
## - Methods for calculating p-values with mixed(): 'KR', 'S', 'LRT', and 'PB'
## - 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
## - NEWS: library('emmeans') now needs to be called explicitly!
## - Get and set global package options with: afex_options()
## - Set orthogonal sum-to-zero contrasts globally: set_sum_contrasts()
## - For example analyses see: browseVignettes("afex")
## ************
## 
## Attaching package: 'afex'
## The following object is masked from 'package:lme4':
## 
##     lmer
library("emmeans")

data(md_12.1)
md_aov <- aov_ez(
  id = "id"
  , dv = "rt"
  , data = md_12.1
  , within = c("angle", "noise")
)

emmeans(md_aov, ~ angle * noise)
##  angle noise   emmean SE   df lower.CL upper.CL
##  X0    absent     462 29 19.8      402      522
##  X4    absent     510 29 19.8      450      570
##  X8    absent     528 29 19.8      468      588
##  X0    present    492 29 19.8      432      552
##  X4    present    660 29 19.8      600      720
##  X8    present    762 29 19.8      702      822
## 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95

For the following example, we want to report pairwise comparisons between experimental conditions. We use afex::aov_ez() for the ANOVA and {emmeans} to preform the pairwise comparisons. However, in addition to the frequentist NHST results, we also want to report Bayes factors for all comparisons. Hence, we need to calculate the Bayes factors and add them to the $table, $statistics, and $full_result elements of the list returned by apa_print().

Comments and Questions


Icons by Icons8