Learn R Programming

plyr (version 1.0.1)

add_margins: Add margins to a data frame.

Description

Add margins to a data frame.

Usage

add_margins(df, rows, cols, margins=TRUE)

Arguments

df
input data frame
rows
names of row margins
cols
names of column margins
margins
Either TRUE to compute all margins, or a character vector of margin names, which may include any name in rows or cols, or "grand_row" or "grand_col".

Details

Rownames are silently stripped. All margining variables will be converted to factors.