Correlations with unordered categorical variables I have a dataframe with many observations and many variables. Some of them are categorical (unordered) and the others are numerical.
I'm looking for associations between these variables. I've been able to compute correlation for numerical variables (Spearman's correlation) but :


*

*I don't know how to measure correlation between unordered categorical variables.

*I don't know how to measure correlation between unordered categorical variables and numerical variables.


Does anyone know how this could be done? If so, are there R functions implementing these methods?
 A: If you want a correlation matrix of categorical variables, you can use the following wrapper function (requiring the 'vcd' package):
catcorrm <- function(vars, dat) sapply(vars, function(y) sapply(vars, function(x) assocstats(table(dat[,x], dat[,y]))$cramer))

Where:
vars is a string vector of categorical variables you want to correlate
dat is a data.frame containing the variables
The result is a matrix of Cramer's V's.
A: Depends on what you want to achieve.  Let $X$ be the continuous, numerical variable and $K$ the (unordered) categorical variable.  Then one possible approach is to assign numerical scores $t_i$ to each of the possible values of $K$, $i=1, \dots, p$. One possible criterion is to maximize the correlation between the $X$ and the scores $t_i$.  With only one continuous and one categorical variable,  this might not be very helpful, since the maximum correlation will always be one (to show that, and find some such scores, is an exercise in using Lagrange multipliers!  With multiple variables, we try to find compromise scores for the categorical variables, maybe trying to maximize the multiple correlation $R^2$.  Then the individual correlations will not more (except very special cases!) equal one.  
Such an analysis can be seen as a generalization of multiple correspondence analysis, and is known under many names, such as canonical correlation analysis, homogeneity analysis, and many others. An implementation in R is in the homals package (on CRAN).  googling for some of this names will give a wealth of information, there is a complete book:  Albert Gifi, "Nonlinear Multivariate Analysis".  Good luck!
A: I had a similar problem and I tried the Chi-squared-Test as suggested but I got very confused in assessing the P-Values against NULL Hypothesis. 
I will explain how I interpreted categorical variables. I am not sure how relevant it is in your case. I had Response Variable Y and two Predictor Variables X1 and X2 where X2 being a categorical variable with two levels say 1 and 2. I was trying to fit a Linear Model
ols = lm(Y ~ X1 + X2, data=mydata)

But I wanted to understand how different level of X2 fits the above equation. I came across a R function by()
by(mydata,X2,function(x) summary(lm(Y~X1,data=x)))

What this code does is, it is trying to fit in Linear Model for each level of X2. This gave me all P-value and R-square, Residual standard error which I understand and can interpret. 
Again I am not sure if this is what you want. I sort of compared different values of X2 in predicting Y.
A: I've seen the following cheatsheet linked before:
https://stats.idre.ucla.edu/other/mult-pkg/whatstat/
It may be useful to you. It even has links to specific R libraries.
A: It depends on what sense of a correlation you want.  When you run the prototypical Pearson's product moment correlation, you get a measure of the strength of association and you get a test of the significance of that association.  More typically however, the significance test and the measure of effect size differ.  
Significance tests: 


*

*Continuous vs. Nominal:  run an ANOVA.  In R, you can use ?aov.  

*Nominal vs. Nominal: run a chi-squared test.  In R, you use ?chisq.test.  


Effect size (strength of association):  


*

*Continuous vs. Nominal:  calculate the intraclass correlation.  In R, you can use ?ICC in the psych package; there is also an ICC package.  

*Nominal vs. Nominal: calculate Cramer's V.  In R, you can use ?assocstats in the vcd package.  

A: To measure the link strength between two categorical variable i would rather suggest the use of a cross tab with the chisquare stat
to measure the link strength between a numerical and a categorical variable you can use a mean comparison to see if it change significally from one category to an others
