you should definitly use quantmod
, and you can. The quantmod
methods monthlyReturn, dailyReturn, ..., allReturns
require an xts
time series as input. So if you have daily data (e.g. close price) and the corresponding dates you can construct your time series and pass that to the desired quantmod
method.
Example:
library(package="quantmod")
prices <- c(7655.88, 7612.39, 7612.39, 7778.78, 7756.44, 7776.37)
dates <- as.Date(c("2012-12-26", "2012-12-27", "2012-12-30", "2013-01-01", "2013-01-02", "2013-01-03"))
ts <- xts(prices, dates)
dailyReturn(ts)
monthlyReturn(ts) # this will return bogus data because we don't have one month of data in this example