Learn R Programming

papaja (version 0.1.0.9449)

apa_table: Prepare table for printing

Description

Formats matrices and data.frames to report them as tables according to APA guidelines (6th edition).

Usage

apa_table(x, caption = NULL, note = NULL, stub_indents = NULL, added_stub_head = NULL, col_spanners = NULL, midrules = NULL, placement = "tbp", landscape = FALSE, small = FALSE, ...)
apa_table.latex(x, caption = NULL, note = NULL, col_spanners = NULL, midrules = NULL, placement = "tbp", landscape = FALSE, small = FALSE, ...)
apa_table.word(x, caption = NULL, note = NULL, ...)

Arguments

x
Object to print, can be matrix, data.frame, or list. See details.
caption
Character. Caption to be printed above the table.
note
Character. Note to be printed below the table.
stub_indents
List. A named list of vectors of length 2 giving the first and second row to indent. Names of list elements will be used as titles for indented sections.
added_stub_head
Character. Used as stub head (name of first column) if row.names = TRUE is passed to kable; ignored if row names are omitted from the table.
col_spanners
List. A named list of vectors of length 2 giving the first and second column to span with a grouping column name.
midrules
Numeric. Vector of line numbers in table (not counting column headings) that should be followed by a horizontal rule; ignored in MS Word documents.
placement
Character. Indicates whether table should be placed at the exact location (h), at the top (t), bottom (b), or on a separate page (p). Arguments can be combined to indicate order of preference (htb); ignored in MS Word documents.
landscape
Logical. If TRUE the table is printed in landscape format; ignored in MS Word documents.
small
Logical. If TRUE the font size of the table content is reduced.
...
Further arguments to pass to kable.

Details

When using apa_table(), the type of the ouput (LaTeX or MS Word) is determined automatically by the rendered document type. If no rendering is in progress the output default is LaTeX.

If x is a list, all list elements are merged by columns into a single table with the first column giving the names of the list elements elements.

See Also

kable

Examples

Run this code

my_table <- apply(cars, 2, function(x) # Create data
   round(c(Mean = mean(x), SD = sd(x), Min = min(x), Max = max(x)), 2)
)

apa_table(
   my_table
   , align = c("l", "r", "r")
   , caption = "A summary table of the cars dataset."
   , note = "This table was created using apa\\_table()"
   , added_stub_head = "Descriptives"
)

Run the code above in your browser using DataLab