Re-Coding Binary Factor

Dear All,

I noticed that R recognises a binary factor in terms of two levels: "1", "2."

Yet, I am using some analysis which only accepts variables on the interval [0,1].

Therefore, would it be possible for someone indicate how it is possible to coerce a two-level factor to take on the levels 0-1?

I've tried various methods. But it still seems to code them as 1,2.

Any help would be appreciated.

(original_factor <- factor(rep(1:2,7)))

(not_a_factor <- as.integer(original_factor) - 1L )

Thanks @nirgrahamuk . I'll try that!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.