Learn R Programming

papaja (version 0.1.0.9054)

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(...)
apa_table.latex(x, caption = NULL, note = NULL, row_names = TRUE, added_colnames = NULL, midrules = NULL, placement = "tbp", landscape = FALSE, ...)
apa_table.word(x, caption = NULL, note = NULL, row_names = TRUE, added_colnames = NULL, ...)

Arguments

...
Further arguments to pass to kable. row.names argument is overwritten by row_names.
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.
row_names
Logical. Indicates whether to include row names; by default, row names are included if rownames(x) is neither NULL nor identical to 1:nrow(x). Overwrites the corresponding kable argument.
added_colnames
Character. Vector of names for first unnamed columns. See details.
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.

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.

If the first column(s) of the table are unnamed, names for these columns can be supplied using the added_colnames parameter. This can be done, e.g., when an object has rownames (unless row.names = FALSE is passed to kable) and when elements of a list are merged. It is generally recommended to use row_names instead of row.names.

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_colnames = "Descriptives"
)

Run the code above in your browser using DataLab