prepare: Table by group

prepareR Documentation

Table by group

Description

prepare prepare formats body from long to wide by given factor and collects variables from original data for later. Output is an S4 object containing the table and ancillary information to be used for table formatting in when printing as html.

Usage

prepare(object, variable_col, by_col = "all")

Arguments

object

A data frame containing the layout table body.

variable_col

A character element with the name of the column containing variable names.

by_col

A character element with specifying the column containing the factor used for grouping. Set to 'all' for single group.

Value

An S4 object. the object@body contains the table with one row per variable and a set of display columns for each level of the grouping variable.

See Also

layout_html for html tables.

Other table layout: add_colgroup(), add_cols(), add_rowgroup(), add_units(), firstrow_css(), layout_html(), order_by_vector(), order_layout(), print_abbrev(), query_abbrev()

Examples

## Create an S4 object, optionally adding specifications for the slots
example_layout <- new('layout',
                     caption = 'Example table',
                     footer = 'Flower petal dimensions by species.',
                     body = dta_length) # using patel length as body
## Prepare the layout object
example_layout <- prepare(example_layout,
                          variable_col= 'key',
                          by_col = "Species")
## Get petal width data
example_layout_width <- new('layout',
                      body = dta_width) 
## Prepare the layout object for petal width
example_layout_width <- prepare(example_layout_width,
                          variable_col= 'key',
                          by_col = "Species")

eeenilsson/layout documentation built on Sept. 26, 2022, 8:14 p.m.