sprintf.ca: Print number to fit certain format. An alternative is used if...

Description Usage Arguments Value Author(s)

View source: R/sprintf-ca-function.R

Description

This is a variation of sprintf, that checks if the formated result is too long. This can happen, for example, with electrometer output, where normal results are 0.004 pC and then an overflow gives a charge of 6e47 C, which produces an output that ruins txtplot table output.

Usage

1
sprintf.ca("%.5f", c(1.23, 2.33, 1e99), max.chars=7)

Arguments

format

is the main format (e.g. "%.5f") which is used if the output does not require too many characters.

number

to print (e.g. 1.334 or 1.4e99).

format.alt

is the alternative format (e.g. "%.4e") which is used for output that require too many characters.

max.char

is the maximum number of characters (e.g. 10) that the main format needs to fit (otherwise the alternative format will be used).

Value

formated number.

Author(s)

Claus E. Andersen


claus-e-andersen/clanTools documentation built on Oct. 23, 2020, 7:59 a.m.