I have two ordered factors and simply want to find Spearman's rho between them.
However:
> cor(dat$UEMS.2,dat$SCIM23_SubScore1.2,use="pairwise.complete.obs",method="spearman")
Error in cor(dat$UEMS.2, dat$SCIM23_SubScore1.2, use = "pairwise.complete.obs", :
'x' must be numeric
And just as a sanity check:
> class(dat$UEMS.2)
[1] "ordered" "factor"
> class(dat$SCIM23_SubScore1.2)
[1] "ordered" "factor"
How do I find spearman's rho for ordered factors using R?
I did find the following: Calculate correlation - cor() - for only a subset of columns
Which raises the same issue: R's cor() function only accepts numerical data. This doesn't seem right to me, because spearman's rho should be able to handle ordinal variables. Ordered factors are ordinal variables.
Thanx in advance.