Put the data into a list, not into individual variables. Something
like this (untested):
L - sapply(symbols[-length(symbols)],
get.hist.quote, start = 2005-01-09, quote = Close, simplify = FALSE)
mat - do.call(cbind, L)
cor.mat - cor(mat, use = complete)
symnum(cor.mat)
On 8/29/06, BBands [EMAIL PROTECTED] wrote:
R 2.3.1
I wrote a little script to do some cross correlations. The symbols are
in a text file like so:
symbols.txt
ibm
dd
csco
require(tseries)
symbols - scan(symbols.txt, what = 'character')
for(line in 1:(length(symbols)-1)) {
assign(symbols[line], get.hist.quote(instrument = symbols[line],
start = 2005-09-01, quote = Close))
}
# this results in objects ibm, dd... with the last symbol skipped
mat - cbind(symbols) # this is the problem
(cor_mat - cor(mat))
symnum(cor_mat)
How can I pass a list of the objects to cbind()? As written cbind gets
only the names of the objects and binds the names not the objects.
Thanks in advance,
jab
--
John Bollinger, CFA, CMT
www.BollingerBands.com
If you advance far enough, you arrive at the beginning.
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.