I'm trying to use the instruction relevel to redefine the refrence category in a factor to the last category.
At first, I got an error:
base1 <- within(base1, DPROS <- relevel(DPROS, ref = 4))  
Error in relevel.default(DPROS, ref = 4) : 'relevel' only for factors
I used the des instruction of the epicalc package to check if DPROS was numeric or factor:
des(base1)
No. of observations =  380   
  Variable      Class           Description  
1 CAPSULE       numeric                    
2 AGE           numeric                    
3 DPROS         numeric                    
4 DCAPS         numeric                    
5 PSA           numeric  
I used as.factor to make DPROS a factor.
DPROS <- as.factor(DPROS)
But I still got the same error:
base1 <- within(base1, DPROS <- relevel(DPROS, ref = 4))  
Error in relevel.default(DPROS, ref = 4) : 'relevel' only for factors
Using des it still said DPROS was numeric, but is.factor(DPROS) returned TRUE.
What am I doing wrong?
 
     
    