How can I create a correlation matrix in R?
An example, d <- data.frame(x1=rnorm(10), x2=rnorm(10), x3=rnorm(10)) cor(d) # get correlations (returns matrix)
An example, d <- data.frame(x1=rnorm(10), x2=rnorm(10), x3=rnorm(10)) cor(d) # get correlations (returns matrix)
Rather “less” look like, but worth checking (as giving more visual information): Correlation matrix ellipses: Correlation matrix circles: Please find more examples in the corrplot vignette referenced by @assylias below.
You can use DataFrame.values to get an numpy array of the data and then use NumPy functions such as argsort() to get the most correlated pairs. But if you want to do this in pandas, you can unstack and sort the DataFrame: import pandas as pd import numpy as np shape = (50, 4460) data … Read more
Without actual data it is hard to answer the question but I guess you are looking for something like this: Top15[‘Citable docs per Capita’].corr(Top15[‘Energy Supply per Capita’]) That calculates the correlation between your two columns ‘Citable docs per Capita’ and ‘Energy Supply per Capita’. To give an example: import pandas as pd df = pd.DataFrame({‘A’: … Read more