I downloaded some stock data:
require("quantmod")
s <- c("AAPL", "ADBE", "ADI", "ADP", "ADSK")
e <- new.env()
getSymbols(s, src='yahoo', from='2015-01-10', env = e )
#get closing prices
close <- do.call(merge, eapply(e, function(x) Cl(x)))
I found all the pairs of symbol names:
#find all the pairwise permutations
perm<-combn(s,2)
perm
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] "AAPL" "AAPL" "AAPL" "AAPL" "ADBE" "ADBE" "ADBE" "ADI" "ADI" "ADP"
[2,] "ADBE" "ADI" "ADP" "ADSK" "ADI" "ADP" "ADSK" "ADP" "ADSK" "ADSK"
I'd like to take the "close" data for each name and replace for each pair group of "perm" to be able to analyse the pairs later.