Correlation between matrices in R I have problems in using the cor() and cor.test() functions.
I just have two matrices (only numerical values, and the same number of
row and columns) and I want to have the correlation number and the 
corresponding p-value.
When I use cor(matrix1, matrix2) I get the correlation coefficients for all the cells.
I just want a single number as result of cor.
In additon when I do cor.test(matrix1, matrix2) I get the following error 
Error in cor.test.default(matrix1, matrix2) : 'x' must be a numeric vector

How can I get p-values for matrices?
You find the simple tables I want to correlate here:
http://dl.dropbox.com/u/3288659/table_exp1_offline_MEANS.csv
http://dl.dropbox.com/u/3288659/table_exp2_offline_MEANS.csv
 A: You haven't said anything about what your data actually is.  Nevertheless...
Suppose that your matrices have columns representing two sets of (different) variables and (the same number of) rows representing cases.  
Canonical Correlation Analysis
In this situation, one potentially interesting more structured correlation analysis is to find the canonical correlations.  This assumes that you want to summarize the relationship between the two sets of variables in terms of the correlation(s) between linear combinations of matrix1 columns and linear combinations of matrix2 columns.  And you would want to do that if you suspected that there was a space of small dimensionality, perhaps even 1, that would reveal an underlying correlation structure across the cases that is obscured by their realization in the current variable-defined coordinate systems.  Consequently the value of this (canonical) correlation would, in a sense, summarize a multivariate linear relationship between the two matrices.  Indeed, while CCA works for matrices with different numbers of variables it reduces to Pearson correlation when each 'matrix' is just a single column.
Implementation
Canonical correlation analysis is described in most multivariate analysis texts, which is perhaps most helpful if you happy with matrix algebra up to eigenanalysis.  It is implemented as cancor in base R and also in the CCA package which is described here.
A: If you loosely construe correlation to mean similarity, you can use a definition based on the inner product, such as:
$c_{AB} = \dfrac{\langle A, B \rangle}{\|A \| ||B\|}$ where $\langle A,B \rangle \equiv \mathrm {tr}(A B^T)$ and $\| x || \equiv \langle x,x \rangle^{1/2}$
With your data this yields 0.996672.
The alternative, if the matrix structure is not important, is to simply flatten the matrices into vectors and use the correlation measure of your choice. Since I don't know your data's distribution I used the dot product, to get 0.976.
Eithe3r way, it seems your data is highly correlated.
A: If you simply want to calculate the correlation between the two sets of values, ignoring the matrix structure, you can convert the matrices to vectors using c(). Then your correlation is computed by cor(c(matrix1), c(matrix2)).
A: You may want to look into fast distance covariance and correlation
which I think R probably has an implementation of.
The answers above have details for R programming to get the
Pearson correlation coefficient which is what you asked for.
To explore distance correlation here is a quick summary of
some steps you could take. The code is in java, but you could port
it to R.
To only calculate the correlation between the the same column
in each of the 2 datasets of the
same size and number of variables, matrix1 and matrix2,
you are calculating only the diagonal of a full correlation matrix.
And you are wanting to combine those correlations into
one number to use as a replacement for similarity between the
2 matrices.
let x1 = matrix1 and x2 = matrix2 below
input: double[][] x1 and double[][] x2 being same size
double[][] dCor = zeros(x1[0].length, x2[0].length);
double[] tmp1 = new double[x2.length];
double[] tmp2 = new double[x2.length];
int i, j, k;
for (i = 0; i < x1[0].length; ++i) {
    //for (j = 0; j < x2[0].length; ++j) {
        j = i
        // copy each column vector to calculate correlation
        for (k = 0; k < x2.length; ++k) {
            tmp1[k] = x2[k][j];
            tmp2[k] = x1[k][i];
        }
        // fast dcor runtime is O(n*log_2(n))
        dCor[i][j] = sqrt(fastDCor(tmp1, tmp2).corSq);
    //}
}

where fastDCor is fast distance correlation.
reference:
"A fast algorithm for computing distance correlation"
2019 Chaudhuri and Hu, Computational Statistics And Data Analysis,
Volume 135, July 2019, Pages 15-24.

For combining correlation0 with correlation 1 and correlation2 etc.
you could browse the short paper:
Charter and Alexander 1993, "A Note on Combining Correlations".

The paper details are for the Pearson correlation, but are informative.
