I would like to calculate the correlation and the p value of that correlatio of each species (bac) to each of the factors (fac) in a second data frame. Both were measured at
If you restructure your data, such that you compute correlation between paired columns, it would be super easy.
tbac <- data.frame(t(bac))
tfac <- data.frame(t(fac))
f <- function (x, y) cor(x, y)
tab <- outer(tfac, tbac, Vectorize(f))
as.data.frame.table(tab)
I had an answer using the same idea: Match data and count number of same value.