I want to find Spearman's rank correlation rho value between these variables.
V1 V2 V3 V4
A SUV Yes Good
A SUV No Good
B SUV No Good
B SUV Yes Satisfactory
C car Yes Excellent
C SUV No Poor
D SUV Yes Poor
D van Yes Satisfactory
E car No Excellent
corr <- cor.test(x=df$V2, y=df$V3, method = "spearman")
corr
On passing the code , I received the following error (Error 1)
Error in cor.test.default(x = df$V2, y = df$V3, method = "spearman") :
'x' must be a numeric vector
What I tried?
Based on this discussion in stack overflow: How to convert a data frame column to numeric type?
transform(df, V2 = as.numeric(V2))
However, on passing the above code I receive following error (Error 2) and error 1 message keeps appearing even after transformation.
Warning message:
In eval(substitute(list(...)), `_data`, parent.frame()) :
NAs introduced by coercion