number: 'number' vector

View source: R/number.R

numberR Documentation

number vector

Description

This creates a formatted double vector. You can specify the number of digits you want the value to display after the decimal, and the underlying value will not change. Additionally you can explicitly set whether scientific notation should be used and if numbers less than 0 should contain a leading 0.

Usage

number(x = numeric(), digits = 3L, scientific = FALSE, leading_zero = TRUE)

is_number(x)

as_number(x)

Arguments

x
  • For number(): A numeric vector

    • For is_number(): An object to test

    • For as_number(): An object to coerce to a number

digits

The number of digits to display after the decimal point.

scientific

Whether the number should be represented with scientific notation (e.g. 1e2)

leading_zero

Whether a leading zero should be used on numbers less than 0 (e.g. .001)

Value

An S3 vector of class supernova_number. It should behave like a double, but be formatted consistently.

Examples

number(1:5, digits = 3)

supernova documentation built on Nov. 5, 2023, 1:09 a.m.