Hi everyone!

I have two variables (v_10_2_24 and v_10_2_24).

I need to make a correlation between those to but first i am asked to eliminate unwanted data from both of them before using "cor"

This is how it looks:

valoracionv<-subset(colmun,subset=v_10_2_24!=997&v_10_2_24!=998&v_10_2_24!=999)

rol<-subset(colmun,subset=v_10_4_3!="ns")

rol2<-subset(rol,subset=v_10_4_3!="nc")

The problem is that when I try to operate them or to correlate them there is a mistake which says that both variables have different lengths, so there is an error which says that the length of the variables is different so the cannot be correlated.

also, when i try to correlate them now, there is another mistake which says that my variable need to be changed to numeric but I really need it as a factor.

If anyone could help me I'll be very thankful