Learn R Programming

stocks (version 1.1.1)

ratios: Ratios of Subsequent Elements in a Numeric Vector

Description

Calculates vector of ratios of a numeric vector, i.e. ratio of x[2] to x[1], ratio of x[3] to x[2], and so forth.

Usage

ratios(x)

Arguments

x
Numeric vector.

Value

Numeric vector.

Details

NA

References

Acknowledgment: This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-0940903.

See Also

NA

Examples

Run this code
# Randomly generate 10 values from a standard normal distribution
x <- rnorm(10)

# Calculate vector of ratios
y <- ratios(x)

# View results
x
y

Run the code above in your browser using DataLab