The formula is simply: overall.rate = prices[length(prices)] / prices[1] - 1. If xday is specified, then it converts to x-day growth rate. For example, if prices is a vector of stock prices over a five-day period, say c(100.4, 98.7, 101.3, 101.0, 100.9), then the overall growth rate is approximately 0.0050 over four full trading days. If xday.rate is set to 1, this rate is converted to an average daily rate of approximately

1 | ```
prices.rate(prices, xday.rate = NULL, nas = FALSE)
``` |

`prices` |
Numeric vector of stock prices or investment balances. Has to be daily prices if you want to calculate x-day rather than overall growth. |

`xday.rate` |
Number of days for growth rate calculation. If unspecified, function returns overall growth. If set to 251, function would return annual growth rate. |

`nas` |
If TRUE, function finds and removes any missing values (NA's) in prices vector. The default is FALSE to maximize speed for the usual case where there are no missing values. |

Numeric value indicating the growth rate.

Dane R. Van Domelen

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

1 2 3 4 5 6 7 8 9 10 11 | ```
# Create vector of daily closing prices for a hypothetical stock
prices <- c(100.4, 98.7, 101.3, 101.0, 100.9)
# Overall growth is 0.50%
prices.rate(prices)
# Average daily growth is 0.12%
prices.rate(prices, 1)
# Corresponds to 36.6% annual growth
prices.rate(prices, 251)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.