Learn R Programming

supernova (version 3.0.0)

number: 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)

Value

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

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)

Examples

Run this code
number(1:5, digits = 3)

Run the code above in your browser using DataLab