Skip to contents

stm_linspace() generates a vector of linearly spaced values from from to to, with a specified number of points n.

Usage

stm_linspace(from, to, n = 50, digits = NULL)

Arguments

from

A numeric value representing the start of the sequence.

to

A numeric value representing the end of the sequence.

n

Optional. A positive integer specifying the number of points in the sequence. Default is 50.

digits

Optional. An integer specifying the number of decimal places to round the result. Default is NULL.

Value

A numeric vector of length n with linearly spaced values from from to to.

Details

This function generates a sequence of values with equal spacing between them, which is useful for creating plots or numerical grids. If digits is provided, the resulting vector will be rounded to the specified number of decimal places.

Examples

stm_linspace(from = 0, to = 1, n = 7)
#> [1] 0.0000000 0.1666667 0.3333333 0.5000000 0.6666667 0.8333333 1.0000000
stm_linspace(from = 0, to = 1, n = 7, digits = 4)
#> [1] 0.0000 0.1667 0.3333 0.5000 0.6667 0.8333 1.0000