I have, for example, a list of 5 vectors and would like to compare each one of them. Example
L = list(c(1:5), c(-1:-5), c(3:7), c(-4:-8), c(5:9))
[[1]]
[1] 1 2 3 4 5
[[2]]
[1] -1 -2 -3 -4 -5
[[3]]
[1] 3 4 5 6 7
[[4]]
[1] -4 -5 -6 -7 -8
[[5]]
[1] 5 6 7 8 9
I have also a function to make pairwise comparisons between the 5 elements of the list:
foo = function(x, y) t(x) %*% abs(y)
I would like to apply foo
to make pairwise comparisons of my list. For example:
Pairwise comparisons (the 'x' and 'y' of foo):
[[1]]and [[2]]
[[1]]and [[3]]
[[1]]and [[4]]
[[1]]and [[5]]
[[2]]and [[3]]
[[2]]and [[4]]
[[2]]and [[5]]
[[3]]and [[4]]
[[3]]and [[5]]
[[4]]and [[5]]
...
My original file has 1000 elements
I tried using: lapply(L, foo) but I have the following message error: ```argument "y" is missing, with no default````
How can I apply foo to my list?