I have a stock symbol vector / etf that varies depending on my interests.
Example:
symbols_v <- c('UPRO','TLT','SPXU','TBT','DRN','URE','SOXL')
I would like to use the combination rule, two at a time for iterating over a vector, for generating pairs.
Example:
p <- combn(symbols_v, 2)
Each pair of p must be transferred to a (user-defined) function with two parameters " f(x,y) ", which will load the stock data and perform correlations and other functions.
My questions are: 1) What would be the best data structure for p for step 2 below? 2) Given the data structure p, what is the easiest way to parse it in order to pass pairs to the function f?
Summary: how to take the results of the combn() function and pass each pair to the f(x,y) function?
I am trying to minimize the loop since this is considered "slow" in R.
I am probably absent from something fundamental, but I apparently cannot help but hug him around.
Please feel free to insult my intelligence by providing an answer :)
source share