Convert a numeric vector into a character vector with the specified number of decimal place

Share:

Description

formatted convert a numeric vector into a character vector with the specified number of decimal place.

Usage

1
formatted(x, digits = 2)

Arguments

x

a numeric vector

digits

the specified number of decimal places (default 2)

Value

Return a character vector.

Author(s)

Yasuyuki Okumura
Department of Social Psychiatry,
National Institute of Mental Health,
National Center of Neurology and Psychiatry
yokumura@blue.zero.jp

Examples

1
2
3
4
data(infert)
x <- svar(infert$age)    #sample variance
formatted(x)
formatted(x, digits=4)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.