R programming purpose of converting binary to factor

Viewed 60

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.

1 Answers

Two possible reasons:

  1. it is more descriptive, and so easier to understand and less likely to mistake for something else
  2. 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).
Related