r - How can I download a set of prices with getSymbols and store them in the order it was requested? -


I download historical prices for quantmod with the getSymbols function for many tickers and By changing a list or following the following code, a multivariate XTS:

  library (quantmod) myenv & lt; - new.env () Ticker & lt; - Convert the list to "c" ("^ GSPC", "AAPL", "MSFT", tas (l); do.call (merge, (eapply (myenv,).))) # Multivirate exts Convert and remove only the adjusted value   

The problem I have from this perspective is that the order of the ticker and XTS in the list is not the same as I specified in the ticker Done:

  & gt; Name (ll) [1] "AAPL" "GSPC" "GOOG" "Root" "MSF" & gt; Name (SS) [1] "Adjusted AAPL." "GSPC Adjusted" "GOOG.Adjusted" "RUT.Adjusted" [5] "MSFT.Adjusted"   

I think that This is because eapply operates in a random order, as in the help pages of eapply :

The order is arbitrary for the hashed environment.

How can I do the same operation above, but how can I get my output in the same order as my tickers specified in vector? To wit. The first item of the list / the first column of XTS should correspond to the ticker vector and similar first element.

You can simply reduce the results of eapply in the desired order.

  library (quantmod) ticker & lt; -c ("^ GSPC", "AAPL", "MSFT", "GOG", "^ RUT") INNUEN (MSF), MINV & Lt; - new.env () Symimyms & lt; - getSymbols (Ticker, NV = myenv) #setSymbols Adjusted Name ts & lt; -Call (Merge, Ipli (Maneve, Ed) [Symme])    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -