Learn R Programming

hhmR (version 0.0.1)

exp_seq: exp_seq

Description

Creates a vector of exponentially increasing values between 0 and a specified value `n`. If `n` is specified as 1, the vector will be scaled to between 0 and 1.

Usage

exp_seq(n, ln = 15, exponent = 2, round_values = TRUE, rmv_extremes = TRUE)

Value

A vector containing exponentially increasing values between 0 and a specified value `n`.

Arguments

n

The maximum value that the values in the sequence are scaled to.

ln

How long the vector should be (defaults to 15).

exponent

The exponential power with which to multiply the sequence by (defaults to 2).

round_values

Option to round values to whole numbers (defaults to `TRUE`). If `n` equals 1, round_values will automatically be set to FALSE.

rmv_extremes

Option to remove zero and the maximum value (i.e. `n`) from the beginning and the end of the returned vector (defaults to `FALSE`). Note that this will mean the length of the returned vector will be `n` - 2.

Examples

Run this code
# Create sequence of length 8, scaled between 0 and 10000
exp_seq(10000,8)
# Set rmv_extremes = FALSE to get full sequence
exp_seq(10000,8,rmv_extremes = FALSE)
# The exponent defaults to 2. Setting it to between 1 and 2 causes it to converge on
# a linear sequence. When exponent is set to 1 the sequence increases linearly
exp_seq(10000,8,exponent=1)
# Setting it to greater than 2 will cause it the values in the sequence to shift towards zero
exp_seq(10000,8,exponent=4)

# Create sequence of length 12, scaled between 0 and 1
exp_seq(1,12)
exp_seq(1,12,rmv_extremes = FALSE)
exp_seq(1,12,exponent=1)
exp_seq(1,12,exponent=4)

Run the code above in your browser using DataLab