'R programming purpose of converting binary to factor
We can assume that a column is regarded as binary as long as
it is not all NA and aside from NAs it is made up only of numeric 0 and 1 values. I noticed some people will convert binary 0, 1 to No, Yes. Is there a good reason for this?
is it for modeling such as logit, svm or decision tree where factor perform better? i can't find the answer anywhere.
Solution 1:[1]
Two possible reasons:
- it is more descriptive, and so easier to understand and less likely to mistake for something else
- it needs to be a factor, because factors are handled differently, although there is no reason you cannot have a factor with labels "0" and "1", but see 1).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user2974951 |
