Re: [R] passing namees

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed 30 Aug 2006 - 02:24:54 EST

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 <bbands@gmail.com> 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. Received on Wed Aug 30 02:28:56 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 30 Aug 2006 - 04:30:22 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.