I have a dataframe called EWMA_SD252 3561 obs. of 102 variables (daily volatilities of 100 stocks since 2000), here is a sample :
Data IBOV ABEV3 AEDU3 ALLL3
3000 2012-02-09 16.88756 15.00696 33.46089 25.04788
3001 2012-02-10 18.72925 14.55346 32.72209 24.93913
3002 2012-02-13 20.87183 15.25370 31.91537 24.28962
3003 2012-02-14 20.60184 14.86653 31.04094 28.18687
3004 2012-02-15 20.07140 14.56653 37.45965 33.47379
3005 2012-02-16 19.99611 16.80995 37.36497 32.46208
3006 2012-02-17 19.39035 17.31730 38.85145 31.50452
What i am trying to do is using a single command, to subset a interval from a particular stock using dates references and also plot a chart for the same interval, so far i was able to do the subset part but now i am stuck on plotting a chart, here is what i code so far :
Getting the Date Interval and the stock name :
datas = function(x,y,z){
intervalo_datas(as.Date(x,"%d/%m/%Y"),as.Date(y,"%d/%m/%Y"),z)
}
Subsetting the Data :
intervalo_datas <- function(x,y,z){
cbind(as.data.frame(EWMA_SD252[,1]),as.data.frame(EWMA_SD252[,z]))[EWMA_SD252$Data >= x & EWMA_SD252$Data <= y,]
}
Now i am stuck, is it possible using a function to get ABEV3 data.frame and plot a chart using dates in X and volatility in y, using just the command bellow ?
ABEV3 = datas("09/02/2012","17/02/2012","ABEV3")


