table_format: Round Numeric Columns of a Table

Description Usage Arguments Value Author(s) See Also Examples

View source: R/tables.R

Description

This function returns a table with numeric columns rounded accordingly the specified number of decimal digits. Numeric columns are coverted to character after rounding.

Usage

1

Arguments

table

a data frame.

digits

a vector with non negative integer values with length equals the number of columns of table. These number represent the number of digits used to round numeric values. The number is ignored when the correponding column isn't numeric. NA and negative values are ignored.

Value

a table with column rounded to the number of decimal digits specified. All columns are coverted to character, so numeric functions can not be direct applied to them anymore. Because of this, it is not recommended assign the result of the function to the object used as table argument.

Author(s)

Walmes Zeviani, walmes@ufpr.br.

See Also

matrix2html().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
x <- table_format(head(rock), digits = c(1, 2, 3, 4))
x
str(x)

x <- table_format(head(iris), c(2, 3, 2, 3, NA))
x
str(x)

x <- table_format(head(rock), c(-1, NA, 3, 4))
x
str(x)

walmes/wzRfun documentation built on Aug. 10, 2021, 2:19 p.m.