fmt {plot.matrix}R Documentation

fmt

Description

Rounds and adds trailing zeros (by default if digits is lower than 4).

Usage

fmt(x, digits = 2L, zeros = digits < 4L, ...)

Arguments

x

numeric: vector.

digits

integer: Digits that should be used for rounding.

zeros

logical: Should trailing zeros be added?

...

passed to format for fmt.

Value

formatted x as text.

Source

Similar to function fmt from the package exams. In the function round2 has been replaced by round.

See Also

exams::fmt

Examples

## this is also employed internally in the fmt() formatting function
fmt(c(0.005, 0.015))

## the main purpose of fmt() is that some numeric result can be displayed
## both at high accuracy and then at the rounding that students should do
## (e.g., with 2 or 3 digits)
sol <- runif(1)
fmt(sol, 6)
fmt(sol, 2)

## but fmt() also assures showing a very high number of significant digits
## (up to 12)
sol <- 123456 + sol
sol
fmt(sol, 6)
fmt(sol, 2)

## and fmt() also takes care of adding trailing zeros (if digits < 4)
fmt(1)
fmt(1, digits = 3)
fmt(1, digits = 6)

[Package plot.matrix version 1.6.2 Index]