How to convert integer into categorical data in R? -
my data set has 8 variables , 1 of them categorical r thinks integer (0's , 1's). have inorder covert categorical?
> str(mydata) 'data.frame': 117 obs. of 8 variables: $ price: int 2050 2080 2150 2150 1999 1900 1800 1560 1450 1449 ... $ sqft : int 2650 2600 2664 2921 2580 2580 2774 1920 2150 1710 ... $ age : int 13 na 6 3 4 4 2 1 na 1 ... $ feats: int 7 4 5 6 4 4 4 5 4 3 ... $ ne : int 1 1 1 1 1 1 1 1 1 1 ... $ cust : int 1 1 1 1 1 0 0 1 0 1 ... $ cor : int 0 0 0 0 0 0 0 0 0 0 ... $ tax : int 1639 1088 1193 1635 1732 1534 1765 1161 na 1010 ...
cor should have been categorical.
have @ ?as.factor
. in case
mydata$cor <- as.factor(mydata$cor)
Comments
Post a Comment