createFSTable: Convert cells in a data frame to HTML text

Description Usage Arguments Details Value See Also

View source: R/FSDTModule.R

Description

This function is useful for creating visually pleasing Financial Statement using the DT Package. Features of this function:

1. numbers are formatted by row by providing row_type vector. supported formats are currecny, percent, comma and accounting. This feature makes use of formattable package.

2. negative numbers can be colored coded to red if color_negative is TRUE

3. supports all css of div tag by surrounding text with <div class="...">your-text</div>.

Usage

1
2
createFSTable(df, id, row_type, row_format_rule = "default", row_css,
  color_negative = TRUE)

Arguments

df

a data frame

id

id columns for the data frame. Columns other than id columns must be numeric

row_type

a character vector, its length must equal to number of rows in df. Types for each row,valid choices are "currency","percent", "comma" and "accounting". To add more valid choices, modify row_format_rule

row_format_rule

when set to default, will use default rules. To customize it, see details section.

row_css

a data frame, it must have the same number of rows as df. column names should be valid css attributes. columns must contain valid values for corresponding attributes.

color_negative

default to TRUE, whether to color numbers smaller than 0 to red

Details

1.row_format_rule:

When row_format_rule is default, it will use the rules in link{FSDTSampleData}.

Now this function supports four formats, which are "currency","percent","comma" and "accounting", it uses functions in formattable package. To customize rules, you must provide a list with the four type names as key. For each key value pair, the value must also be a list with keyword, digits as key. When setting up "currency", you can also use "symbol" as key.

A valid rule should look like list( currency = list(keywords = c("Dollar","amount","currency"), digits = 2, symbol = "$"), percent = list(keyword = c("percent","percentage"),digits = 2), ... etc )

Value

a data frame, cells contains HTML text, which can be parsed by DT::datatable

See Also

FSDTSampleData


yusuzech/shinyEx documentation built on Nov. 5, 2019, 1:22 p.m.