First I created an xts object, which contains 36 time series showing daily prices from 1980-01-02 to 2020-10-06.
ENERGY_data$time <- as.Date(ENERGY_data$time, format("%Y/%m/%d"))
ENERGY_xts <- ENERGY_data[order(ENERGY_data$time), ]
ENERGY_xts <- as.xts(ENERGY_xts[, 2:37], order.by=ENERGY_xts$time)
Then I calculated the continuously compounded daily returns by using the PerformanceAnalytics function CalculateReturns()
ENERGY_returns.cc <- CalculateReturns(ENERGY_xts, method="compound")
Now I would like to calculate the volatility for each month going from 1980-01-02 to 2020-10-06 on the basis of this formula: MONTHLY VOLATILITY FORMULA
Could you please give me some hints (in terms of coding)?