[R-SIG-Finance] Fwd: how to rename stock codes?
Marco Sun
hs13322 at my.bristol.ac.uk
Thu Dec 4 08:57:41 CET 2014
Ok, Ive found a previous solution here https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20100722/1ca9df46/attachment.pl
Begin forwarded message:
> From: Marco Sun <hs13322 at my.bristol.ac.uk>
> Subject: how to rename stock codes?
> Date: 4 December 2014 03:32:12 pm GMT+8
> To: r-sig-finance at r-project.org
>
> Hello Sage R people,
>
>
>
> I am able to retrieve data and rename the stock code one by one through quantmod package as the following:
>
>
>
> symbols<-c("AAPL","MSFT")
>
> stockcodes<-c("A","B")
>
> setSymbolLookup(A=list(name="AAPL",src="yahoo"))
>
> getSymbols("A")
>
> setSymbolLookup(B=list(name=MSFT",src="yahoo"))
>
>
> getSymbols(B")
>
>
>
>
>
> However, the same logic is not approachable in the mass production era like this:
>
>
>
> for (i in 1:2)
>
> {
>
> getSymbolLookup(stockcodes[i]=list(name=symbols[i],src="yahoo"))
>
> getSymbols("stockcodes[i]")
>
> }
>
>
>
> I guess the problem lies in stockcodes[i] as indicated in red. Any comment would be appreciated.
>
>
>
> Thanks in advance,
>
>
>
> Marco
>
[[alternative HTML version deleted]]
More information about the R-SIG-Finance
mailing list