次のようなデータフレームがあります。
d.v <- data.frame(rnorm(13),type="v")
d.w <- data.frame(rnorm(13),type="w")
d.x <- data.frame(rnorm(13),type="x")
d.y <- data.frame(rnorm(13),type="y")
d.z <- data.frame(rnorm(13),type="z")
all<- rbind(d.v,d.w,d.x,d.y,d.z)
colnames(all) <- c("val","type")
library(reshape2)
allM <- melt(all, id.vars = "type")
allList <- split(allM$value, interaction(allM$type, allM$variable))
私がやりたいことは、次のようなマトリックスの組み合わせを作成することです:
[[1]]
v.val v.val
[1,] -0.17392355 -0.17392355
[2,] 0.32196517 0.32196517
[3,] ......
..... # In actuality there are 13 lines for each chunk
[[2]]
v.val w.val
[1,] -0.17392355 0.65036871
[2,] 0.32196517 0.32741115
[3,] ......
..... # In actuality there are 13 lines for each chunk
# etc. in the following combination manner (15 combinations)
# I.e, v-w and w-v are the same, hence we only keep one of them
v-v, v-w,v-x,v-y,v-z,w-w,w-x,w-y,w-z,x-x,x-y,x-z,y-y,y-z,z-z
しかし、次のコードが失敗した理由:
> unlist(lapply(c(1, 3), function(x) lapply(c(1 ,3), function(y) do.call(cbind,allList[c(x,y)]))), recursive=FALSE)
それを行う正しい方法は何ですか?