Skip to content

Latest commit

 

History

History
57 lines (37 loc) · 2.87 KB

README.md

File metadata and controls

57 lines (37 loc) · 2.87 KB

rapa: Report tables and statistics in APA 6 format

Travis-CI Build Status

rapa allows you to dynamically inject R objects (especially tables) into your manuscript and does its best to style them in accordance with APA 6 guidelines. The helper functions in this package return text in either LaTeX or pandoc-style markdown format, making them especially handy when used in combination with RMarkdown.

Installation

Use Hadley Wickham's devtools package:

install.packages("devtools")

library(devtools)

install_github("shamrt/rapa")

Usage

library(rapa)

# APA6-styled correlation matrix
library(Hmisc)
library(xtable)

iris.rcorr <- rcorr(as.matrix(iris[, 1:4]))
iris.rcorr.pp <- rcorr.pp(iris.rcorr)  # Pretty-printed matrix

iris.xtable <- xtable(iris.rcorr.pp)
apa(iris.xtable)

# Report in-line correlation
apa(iris.rcorr, 'Sepal.Length', 'Sepal.Width')

# GLM-based ANOVA
iris.lm.1 <- lm(Sepal.Length ~ Sepal.Width, data = iris)
iris.lm.2 <- update(iris.lm.1, .~. + Petal.Length + Petal.Width)

iris.anova <- anova(iris.lm.1, iris.lm.2)
apa(iris.anova)

Details

The primary reason for rapa's creation is that, while there are packages that do a good job of creating nice LaTeX tables from R objects (e.g., stargazer and xtable), the markup generated by those packages do not easily comply with APA 6 guidelines. Moreover, tables generated by other packages, such as psych, not only fail to comply with the requirements necessary for manuscript publication, they also lack the features and flexibility of more mature table packages. That being so, rapa is intended to provide a thin layer on top of stargazer and xtable such that their respective outputs are formatted as closely to guidelines from the APA 6 manual as possible (i.e. almost always exactly to specifications).

Also included are a few other helper functions that format in-line statistics (e.g., correlations, GLM-generated ANOVAs). Additionally, there is a function (rcorr.pp) that pretty-prints correlation matrices generated by the rcorr function in the Hmisc package --- the output of which can, for example, then be applied to the apa.xtable function included in rapa.

Ultimately, the aim of the rapa package is to eliminate the need to report any statistics in APA format by hand. In its current form, the helper functions provided by rapa barely scratch the surface in terms of the kinds of statistics that psychologists use on a regular basis, so please do not hesitate to contact me if additional helper functions are desired.