I have a for loop containing the following:
for (i in 1:100) {
#calculate correlation
correlationList1a[[i]] <- sapply(seq(1,14),
function(x) cor(validationSetsA.list[[i]][,x], medianListA[[i]]))
correlationList2a[[i]] <- sapply(seq(1,14),
function(x) cor(validationSetsA.list[[i]][,x], medianListB[[i]]))
}
How can I simplify this? correlationList1a
and correlationList2a
are basically doing the same thing the only thing that is different is that correlation1a contains medianListA
and correlationList2a
contains medianListB
.