I have two dataframes df1 and df2 with same number of rows (~2000) and different number of columns. I wanted to do rowwise correlation between these two dataframes. I tried the following codes which I found from the answers in the stack overflow by others, but nothing worked. Is their a solution to this problem?
Df1:
    v1    v2  v3
a1  0.4  0.4 0.3
a2  0.2  0.1 0.5
a3  0.7  0.5 0.6
a4  0.3  0.5 0.9
Df2:
 v1    v2  
a1  0.2  0.4 
a2  0.5  0.9 
a3  0.8  0.5 
a4  0.2  0.6 
cA <- rowMeans(df1)
cB <- rowMeans(df2)
sA <- sqrt(rowMeans(cA^2))
sB <- sqrt(rowMeans(cB^2))
rowMeans(cA * cB) / (sA * sB)
The error shows after the sqrt step :
Error in base::rowMeans(x, na.rm = na.rm, dims = dims, ...) : 'x' must be an array of at least two dimensions
This also din work:
 sapply(1:nrow(df1), function(i) cor(df1[i,], df2[i,]))
I highly appreciate your help!!
