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
We can use expand.grid to get the combinations of rownames of 'bac' and 'fac', loop through the rows with apply specifying the MARGIN as 1, subset the rows of 'bac' and 'fac' based on the rownames, do the corr.test and extract the 'p' values as a list
library(psych)
do.call(c, apply(expand.grid(rownames(bac), rownames(fac)), 1,
function(x) list(corr.test(cbind(unlist(bac[1,]), unlist(fac[1,])))$p)))