form: Form Dataset

Description Usage Arguments Details Value See Also Examples

Description

Forms a dataset by applying flexible rules for numeric formatting, accentuation and filtering.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
form(data, ...)

## S3 method for class 'data.frame'
form(data, format = "%.3f", formatcolumns = list(),
  marker = list(), symbols = list(), groups = list(),
  groups_only = FALSE, filterrows = character(),
  filtercolumns = character())

## S3 method for class 'matrix'
form(data, ...)

## S3 method for class 'table'
form(data, format = "%i", ...)

Arguments

data

A dataset with numeric values and other typed data. Every column will be coerced to character.

format

Default C-formatting (see sprintf) of all numerical values.

formatcolumns

A list with column-specific C-formatting of numerical values. The format is identical to format. Regular expressions (see regex) are used to select the columns by column names. Example for two formattings: list("%2.3f" = c("mean", "std"), "%1.4f" = "pvalue.*"))

marker

A list with marking rules which are going to be applied to user-specified columns of data. Syntax: <rule> = <vektor of regular expressions>. Possible rules include column-wise comparing rules min, max; and arbitrary element-wise comparing rules "...v..." where v is a placeholder for the numeric value of a cell in a logical expression. See Examples.

symbols

A list with symbols to visually highlight all cells where the marking rules of marker applied. Syntax: <symbol> = <vector of regular expressions for marking rules>. Arbitrary symbols are allowed. Examples are "***", "+" or "[v]" and "\mathbf{v}" where v is a placeholder for the (formatted) numeric value of a cell. The marker expressions that can be approached by the regular expressions are <rule>.<group> where <group> is one name specified in groups. <rule>.all refers to the marks from <rule> applied to the whole column.

groups

A list with vectors of regular expressions that are going to be applied to the row names of data. The specfied column-wise marker are applied for each group. Syntax: <groupname> = <vector of regular expressions>. Do not name groups with "." (dot) or "all"!

groups_only

A logical value indicating whether to apply the marker rules only groupwise.

filterrows

A vector of regular expressions which are applied to the row names of data for selecting and sorting the rows of the formatted table. Default: No filtering, all rows are included as they appear.

filtercolumns

A vector of regular expressions which are applied to the column names of data for selecting and sorting the columns of the formatted table. Default: No filtering, all rows are included as they appear.

Details

The function allows the user to format all kinds of numeric or character data on the fly, e.g. resulting output from computations. It can be employed greatly to automatically prepare data and results to review it directly in the R session or to export it to a dynamically designed LaTeX table code via latex.

The package and this function will be improved by missing functionality on a regular basis. The author is eager to receive your suggestions in order to improve the dynamics and power of PlainT and form. Please write to Fabian Raters (mail@qrat.de).

Value

The function returns a formatted character dataset of class form which inherits of data.frame.

See Also

For exporting the formed frame, see latex.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## forming mtcars
mtcarsf <- form(data = mtcars,
                format = "%i",
                formatcolumns = list("%5.1f" = "disp",
                                     "%3i" = "hp",
                                     "%4.1f" = "qsec",
                                     "%4.2f" = c("drat", "wt")),
                marker = list(min = c("mpg", "cyl", "disp", "hp", "drat",
                                      "wt", "qsec"),
                              max = c("mpg", "cyl", "disp", "hp", "drat",
                                      "wt", "qsec"),
                              "v==1" = "am"),
                symbols = list("**v" = "max.all",
                               "..v" = "min.all",
                               "[v]" = "v==1"))

qrat/plaint documentation built on May 26, 2019, 12:34 p.m.