Learn R Programming

qol (version 1.2.1)

modify_number_formats: Modify Number Formats Used by any_table()

Description

Modify previously created number formats with number_format_style().

Usage

modify_number_formats(formats_to_modify, ...)

Value

Returns a modified list of number format options.

Arguments

formats_to_modify

Pre created number formats where only certain elements should be modified while the rest is kept as is.

...

Pass in names and corresponding new values for existing number formats.

Details

modify_number_formats() is based on 'SAS' number formats and the Output Delivery System (ODS), which provides efficient and readable ways to set up different table styles.

With the number format style you have full control over formatting numbers according to the different statistics. There is no need to think about calculating the right place to input the number formats and how to do this in a loop for multiple cells. Just input the different number formats and decimals for the different statistics and everything else is handled by the functions capable of using number styles.

The concept basically is: design over complex calculations.

See Also

Creating a custom table style: excel_output_style(), modify_output_style(), number_format_style().

Global style options: set_style_options(), set_variable_labels(), set_stat_labels().

Functions that can handle styles: frequencies(), crosstabs(), any_table(), export_with_style().

Examples

Run this code
# For default values
format_list <- number_format_style(pct_excel    = "0.00000000",
                                   pct_decimals = 8)

# Set specific options, the rest will be kept as is
format_list <- format_list |> modify_number_formats(sum_excel = "#,###,##0.000")

# IMPORTANT: Don't forget to add individual formats to an excel style, otherwise
# they won't come into affect.
excel_style <- excel_output_style(number_formats = format_list)

Run the code above in your browser using DataLab