fabio crepaldi
2006-Jan-04 19:07 UTC
[R] How to create a correlation table for categorical data???
Hi, I need to create the correlation table of a set of categorical data (sex, marital_status, car_type, etc.) for a given population. Basically what I'm looking for is a function like cor( ) working on factors (and, if possible, considering NAs as a level). To better express myself, the manual way should be: 1) to create a set of n-1 numeric dummies (whose assigned values are 0,1) for each factor of n levels; 2) to cbind them into a data.frame; 3) to apply the cor( ) function to this data.frame. But that takes time and I'll have to do it for several different datasets with different levels... There must be a smartest and quickest way. Is there anybody who can help me??? Many thanks guys, bye. Fabio --------------------------------- [[alternative HTML version deleted]]
Michael Dewey
2006-Jan-05 20:57 UTC
[R] How to create a correlation table for categorical data???
At 19:07 04/01/06, fabio crepaldi wrote:>Hi, > I need to create the correlation table of a set of categorical data > (sex, marital_status, car_type, etc.) for a given population. > Basically what I'm looking for is a function like cor( ) working on > factors (and, if possible, considering NAs as a level).If they are ordered have you considered downloading the polycor package? Michael Dewey med at aghmed.fsnet.co.uk http://www.aghmed.fsnet.co.uk/home.html
Seemingly Similar Threads
- Point biserial correlation => Is there any specific command or could I just use cor.test?
- "metafor" package, proportions: single groups wrt to a categorical dependent variable
- Overlaying density plot on forest plot
- generate random numbers from a multivariate distribution with specified correlation matrix
- Error when naming rows of dataset