0

Hi guys i'm wondering if there is a possibility to add multiple xts-objects into a 3-D-Array.

I want to put multiple Stock-Data from quantmod together in an (n x m x 4) array. the 4 is for respective close, open, high, low price of the stocks.

So at the end i want to have like 4 data-frames in 1 array, divided according to the respective price.

Here some example code:

library (quantmod)
symbols <- c("NVDA", "AAPL", "NFLX")
getSymbols(symbols, env = stocksEnv <- new.env())

abc <- eapply(stocksEnv, function(x) head(x))

I thought something like this list, but for the respective price not the stock.

Thank you already for your answer(s)!

Phil
  • 7,287
  • 3
  • 36
  • 66
nino123
  • 11
  • 2

1 Answers1

0

Add the following lines to your code:

FF <- c("Cl", "Op", "Hi", "Lo")
ABC <- lapply(FF, function(ff) Reduce("merge", lapply(abc, ff)))
names(ABC) <- FF