Learn R Programming

BioGeoBEARS (version 0.2.1)

conditional_format_table: Conditionally format the numbers (mostly) in a table

Description

When a table has numbers that range over many orders of magnitude, it can be very distracting if the display program forces each column to the same format. This function uses conditional_format_cell via sapply to format a cell much like Excel would.

Usage

conditional_format_table(input_table, numbers_below_this_get_scientific = 1e-04, numdigits_for_superlow_scientific = 1, numbers_above_this_get_scientific = 1e+07, numdigits_for_superhigh_scientific = 2, numdigits_inbetween_have_fixed_digits = 4)

Arguments

input_table
The table to format.
numbers_below_this_get_scientific
When the absolute value of a number is below this value, scientific notation is used.
numdigits_for_superlow_scientific
Number of digits after the '.' for scientific notation of small numbers.
numbers_above_this_get_scientific
When the absolute value of a number is above this value, scientific notation is used.
numdigits_for_superhigh_scientific
Number of digits after the '.' for scientific notation of large numbers.
numdigits_inbetween_have_fixed_digits
Numbers of medium size have this many fixed digits. Note that other cutoffs are specified in the code, and signif is used to make e.g. integers appear as 0, 1, 2..

Value

output_table The table, reformatted with cells of class character.

Details

The defaults seem to work well, but could be modified. The current function also extracts just the filename, if a full path is given.

References

http://phylo.wikidot.com/matzke-2013-international-biogeography-society-poster

Matzke_2012_IBS

See Also

signif, sprintf

Examples

Run this code
test=1

input_table = adf(c(143514514514532, -42.235235, -42.0000000,
0.0000, 0.0001, 0.00001, 0.0000111))
conditional_format_table(input_table=input_table)

Run the code above in your browser using DataLab