Correlation Test Between a Categorical Variable and an Ordinal (In the form of a ranking) Variable I have a dataset of book sales by rank and the color of the cover. I would like to find a relationship between the rank of the book and the color of the cover.
I'd like to know how to do this analysis in R.
This is how the dataset looks like:




Book
MainColor
SecondaryColor
Ranking




Book 1
White
Black
1


Book 2
White
Black
2


Book 3
Yellow
Red
3


Book 4
Yellow
Black
4


Book 5
Pink
White
5


Book ...
...
...
...




I'm new to stackexchange and statistics.

If you hve had only one color variable, you could use the rank-basded alternative to one-way anova, which is the Kruskal-Wallis test, see for instance Kruskal-Wallis test data considerations.
But you have two color variables, so the situation is analogous to two-way anova. I would try user Frank Harrell's answer at Is there an equivalent to Kruskal Wallis one-way test for a two-way model?.  For an example (with R code) see Which model should I use to fit my data ? ordinal and non-ordinal, not normal and not homoscedastic
