Using get() to reference columns in quantmod arrays with R?
I'm new to R, using the quantmod() package for a project. The following
block of code works:
require(quantmod)
stocks<-c("MMM", "MSFT", "BP")
for(i in 1:length(stocks)){
getSymbols(stocks[i], from= "2013-07-01")
s<-get(stocks[i])
dr<-dailyReturn(s)
print(paste(dr))
}
However, I need to reference specific columns to calculate some technical
analysis indicators from the TTR package. For example:
open<-MMM$MMM.Open
RSI(open, n=14)
When I check:
identical(s, BP) #TRUE
And this works:
BP$BP.Open
However, this does not work:
s$s.Open #NULL
To provide adequate context, my goal is to go through a vector of stocks,
check for a ]condition, then calculate some technical analysis and time
series figures for that day and copy it into an ARFF file for use as
training examples for a machine learning environment (Weka). Thanks.
No comments:
Post a Comment